Skip to content

Instantly share code, notes, and snippets.

Created December 9, 2016 16:27
Show Gist options
  • Save anonymous/b843bd579041188441f51a7805cf537e to your computer and use it in GitHub Desktop.
Save anonymous/b843bd579041188441f51a7805cf537e 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