Skip to content

Instantly share code, notes, and snippets.

@ramanqul
Forked from anonymous/nginx.conf
Created November 20, 2017 10:36
Show Gist options
  • Save ramanqul/a7b6c02e1c3988f7ee38ae555b768a70 to your computer and use it in GitHub Desktop.
Save ramanqul/a7b6c02e1c3988f7ee38ae555b768a70 to your computer and use it in GitHub Desktop.
if ($request_method = OPTIONS) {
# Handle OPTIONS method
add_header Content-Length 0;
add_header Content-Type text/plain;
return 204;
}
# Headers get added no matter the request method
more_set_headers "Access-Control-Allow-Credentials: true";
more_set_headers "Access-Control-Allow-Methods: GET, POST, PUT, DELETE";
more_set_headers "Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Api-Password";
more_set_headers "Access-Control-Allow-Origin: $allowed_origin";
more_set_headers "Access-Control-Max-Age: 600";
more_set_headers "Vary: Origin";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment