我有一个本地运行的UI,在这里我将远程资源称为arg.kl.com
。我将UI托管在具有以下配置的nginx容器上。但是我仍然在浏览器控制台中收到上述警告。不确定此配置有什么问题。
server {
listen 80;
server_name localhost;
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
location / {
root /usr/share/nginx/html;
index index.html index.htm;
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
location /folders/ {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header 'Access-Control-Allow-Origin' $http_origin;
proxy_set_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
proxy_pass arg.kl.com;
}
}
我在控制台中看到以下错误:
跨源请求被阻止:同源策略禁止阅读 位于的远程资源 http://arg.kl.com:4010/layouts/MV672Scse0-8663-40d8-876d-f.mvhtml。 (原因:CORS标头中缺少令牌“ access-control-allow-headers” CORS飞行前频道中的“ Access-Control-Allow-Headers”。
这是怎么了?