A function that responds to requests made with the HTTP OPTIONS method.
The HTTP OPTIONS method is usually called by consumers attempting to identify the allowed request methods or as part of a CORS preflight request. If defined in this way, the function should respond with a 204 (No Content) status code and header data that indicates which methods are allowed and from which origins.
The value for the "Access-Control-Allow-Origin"
response header determines whether the
response can be shared with a given requesting origin. Its value can be one of "*"
, a
single specific origin URL, or null
as described here.
Due to security concerns, it is recommended that you use a single specific origin URL
whenever possible. If you need to allow more than one origin URL, you should validate
that the requesting origin is allowed access and then echo it back in the response header.
Respond to the request by returning a WixHttpFunctionResponse
object you create using the response()
function.
The options()
function is not a function that you call from your code. You define
the function in a file named http-functions.js in your site's Backend section.
The function is called when your users make HTTP requests using the associated
URLs as described below.
All OPTIONS requests with the following URL will be routed to this function:
Premium sites:
Free sites:
Note: You must publish your site at least once before using both the testing and production endpoints. When you make changes to production endpoints you must publish your site for them to take effect. Testing endpoints will use the latest code in the editor.
The request object.