Skip to content

Instantly share code, notes, and snippets.

@wonderbeyond
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save wonderbeyond/ab576b79a2c5f4065d22 to your computer and use it in GitHub Desktop.

Select an option

Save wonderbeyond/ab576b79a2c5f4065d22 to your computer and use it in GitHub Desktop.
add CORS header with nginx
server {
# ...
# support some sub domains
# `add_header` is not allowed in `server`, so I did the hack.
if ($http_origin ~* "^https?://[\w\-]+\.example\.com$") {
set $allowed_origin $http_origin;
}
add_header "Access-Control-Allow-Origin" $allowed_origin;
# ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment