Error :
if (obj.status == 601) {
# Standard response to a preflight does not have a response
# body, so a 204 No Content is appropriate, though you can
# also send a 200 OK, that works too.
set obj.status = 204;
set obj.response = "No content";
if (req.http.Access-Control-Request-Headers) {
set obj.http.Access-Control-Allow-Headers = req.http.Access-Control-Request-Headers;
}
# Echo the requested origin back to the client. You may like to
# check this against an allowlist of origins instead of blindly
# allowing potentially dsestructive requests from any origin
set obj.http.Access-Control-Allow-Origin = req.http.Origin;
# Client may use this preflight response to authorise future
# requests that would otherwise also require a preflight, so
# to maximise reuse, we'll list all allowed methods here, not
# just the one that was requested. (think carefully before
# adding 'DELETE' to this list!)
set obj.http.Access-Control-Allow-Methods = "GET,HEAD,POST,OPTIONS";
# Setting a cache TTL on the response allows the client to use
# this preflight response for other requests.
set obj.http.Access-Control-Max-Age = "86400";
return(deliver);
}
Recv:
if (req.method == "OPTIONS" && req.http.Origin && (req.http.Access-Control-Request-Method || req.http.Access-Control-Request-Headers) ) { error 601; }
Comments
Post a Comment
Feel Free To Ask...