update cross origin config

This commit is contained in:
moicen
2022-01-19 21:25:53 +08:00
parent 28b2faec9d
commit bfe28d5c5a
+12 -8
View File
@@ -28,15 +28,19 @@ server {
# index index.html; # index index.html;
location /api/v1/ts/ { location /api/v1/ts/ {
proxy_pass http://127.0.0.1:8080/api/v1/ts/;
proxy_set_header Host $host; if ($http_origin !~ [a-z]+\.moicen\.com$) {
proxy_set_header X-Forwarded-For $remote_addr; return 403;
proxy_set_header X-Forwarded-Host $remote_addr;
if ($http_origin ~ [a-z]+\.moicen\.com$) {
proxy_set_header Access-Control-Allow-Origin $http_origin;
proxy_set_header Access-Control-Request-Methods GET,POST,OPTIONS;
} }
proxy_set_header Access-Control-Allow-Headers x-requested-with; add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Max-Age 86400;
if ($request_method = 'OPTIONS') {
return 200;
}
proxy_pass http://127.0.0.1:8080/api/v1/ts/;
} }
} }