Created
March 2, 2019 19:23
-
-
Save tihoho/279e167a268bd8b4e5ba2d626cc18283 to your computer and use it in GitHub Desktop.
simple CORS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
set $cors_origin ""; | |
set $cors_cred ""; | |
set $cors_header ""; | |
set $cors_method ""; | |
if ($http_origin ~* "^http.*\.yourhost\.com$") { | |
set $cors_origin $http_origin; | |
set $cors_cred true; | |
set $cors_header $http_access_control_request_headers; | |
set $cors_method $http_access_control_request_method; | |
} | |
add_header Access-Control-Allow-Origin $cors_origin; | |
add_header Access-Control-Allow-Credentials $cors_cred; | |
add_header Access-Control-Allow-Headers $cors_header; | |
add_header Access-Control-Allow-Methods $cors_method; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment