Skip to content

Instantly share code, notes, and snippets.

@kid
Created June 13, 2017 08:21
Show Gist options
  • Save kid/e6d4fa094e59d19ed958105b6def6532 to your computer and use it in GitHub Desktop.
Save kid/e6d4fa094e59d19ed958105b6def6532 to your computer and use it in GitHub Desktop.
nginx...
if ($cors = "simple") {
set $my_allow_origins "$http_origin";
}
if ($cors = "preflight") {
set $my_allow_origins "$http_origin";
set $my_allow_methods "GET, HEAD, POST, OPTIONS";
set $my_allow_headers "Cache-Control";
}
location / {
expires $expires;
add_header "Access-Control-Allow-Origin" $my_allow_origins;
add_header "Access-Control-Allow-Methods" $my_allow_methods;
add_header "Access-Control-Allow-Headers" $my_allow_headers;
if ($cors = "preflight") {
return 204;
}
try_files $uri /index.html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment