Skip to content

Instantly share code, notes, and snippets.

@Yinchie
Created December 31, 2016 11:26
Show Gist options
  • Save Yinchie/a8cb8ec72aa087ccd5fdaf0696c088b6 to your computer and use it in GitHub Desktop.
Save Yinchie/a8cb8ec72aa087ccd5fdaf0696c088b6 to your computer and use it in GitHub Desktop.
My Ghost blog, NGiNX CORS config.
if ($request_method = "OPTIONS") {
more_set_headers "Access-Control-Allow-Origin: www.itchy.nl";
more_set_headers "Access-Control-Allow-Methods: GET, POST, OPTIONS";
more_set_headers "Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type";
more_set_headers "Access-Control-Max-Age: 1728000";
more_set_headers "Content-Type: text/plain charset=UTF-8";
more_set_headers "Content-Length: 0";
return 204;
}
if ($request_method = "POST") {
more_set_headers "Access-Control-Allow-Origin: www.itchy.nl";
more_set_headers "Access-Control-Allow-Methods: GET, POST, OPTIONS";
more_set_headers "Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type";
}
if ($request_method = "GET") {
more_set_headers "Access-Control-Allow-Origin: www.itchy.nl";
more_set_headers "Access-Control-Allow-Methods: GET, POST, OPTIONS";
more_set_headers "Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment