Nginx
使用 POST 請求時,Access-Control-Allow-Origin 標頭不包含在響應中
我的 nginx 配置中有以下內容:
location / { # CORS add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST' always; proxy_pass http://localhost:8080/guacamole/; # systemd: tomcat9 proxy_buffering off; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_cookie_path /guacamole/ /; access_log off; }
當我向伺服器發送
POST
請求時,Access-Control-Allow-Origin
響應中不存在標頭。但是,當我發送GET
請求時。任何想法為什麼?
我似乎代理覆蓋
Access-Control-Allow-Origin
了響應中的標頭。我通過添加解決了這個問題always
:# CORS add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST' always;