Created
April 5, 2018 16:35
-
-
Save tiancheng91/d98413d1c7c2a6e7e9e5436eed4c475d to your computer and use it in GitHub Desktop.
跨域配置
This file contains 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
# find location in server section | |
location / { | |
# add the following, to enable CORS | |
# CORS OPTIONS | |
if ($request_method = 'OPTIONS') { | |
add_header 'Access-Control-Allow-Origin' '*' always; | |
add_header 'Access-Control-Allow-Headers' 'Range' always; | |
add_header 'Access-Control-Allow-Methods' 'GET, HEAD, OPTIONS' always; | |
add_header 'Content-Length' 0; | |
return 204; | |
} | |
# CORS HEAD | |
if ($request_method = 'HEAD') { | |
add_header 'Access-Control-Allow-Origin' '*' always; | |
add_header 'Access-Control-Expose-Headers' 'Content-Length' always; | |
} | |
# CORS GET | |
if ($request_method = 'GET') { | |
add_header 'Access-Control-Allow-Origin' '*' always; | |
add_header 'Access-Control-Expose-Headers' 'Content-Length, Content-Range' always; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment