cors-support.conf
· 1.0 KiB · Text
原始檔案
set $cors '';
if ($http_origin ~ '^https?://(localhost|www\.qrh\.app|www\.qrh\.hair|qrh\.app|qrh\.hair|stats\.wp\.com|sis-t\.redsys\.es|secure\.gravatar\.com)') {
set $cors 'true';
}
if ($cors = 'true') {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
# required to be able to read Authorization header in frontend
#add_header 'Access-Control-Expose-Headers' 'Authorization' always;
}
if ($request_method = 'OPTIONS') {
# Tell client that this pre-flight info is valid for 20 days
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
1 | set $cors ''; |
2 | if ($http_origin ~ '^https?://(localhost|www\.qrh\.app|www\.qrh\.hair|qrh\.app|qrh\.hair|stats\.wp\.com|sis-t\.redsys\.es|secure\.gravatar\.com)') { |
3 | set $cors 'true'; |
4 | } |
5 | |
6 | if ($cors = 'true') { |
7 | add_header 'Access-Control-Allow-Origin' "$http_origin" always; |
8 | add_header 'Access-Control-Allow-Credentials' 'true' always; |
9 | add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; |
10 | add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always; |
11 | # required to be able to read Authorization header in frontend |
12 | #add_header 'Access-Control-Expose-Headers' 'Authorization' always; |
13 | } |
14 | |
15 | if ($request_method = 'OPTIONS') { |
16 | # Tell client that this pre-flight info is valid for 20 days |
17 | add_header 'Access-Control-Max-Age' 1728000; |
18 | add_header 'Content-Type' 'text/plain charset=UTF-8'; |
19 | add_header 'Content-Length' 0; |
20 | return 204; |
21 | } |
22 | |
23 |