你好,谢谢你的时间
我有一个在端口6000上运行的dotnet核心Web API应用程序和一个角度应用程序,使用nginx i反向代理https://api.asoode.com到donet核心应用程序,https://panel.asoode.com反向代理到angular应用程序
。netnet核心应用程序的nginx配置为:
location / {
root /home/asoode/api;
proxy_pass http://45.82.138.126:6000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' 'panel.asoode.com';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' 'panel.asoode.com';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' 'panel.asoode.com';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
}
我使用了通配符,带有和不带有协议的域,仍然收到CORS错误,
当我使用邮递员和OPTION方法请求api时,我得到了这个结果,这表明panel.asoode.com被允许!!!!!!
我有2个错误,主要是我的错,因为错误消息说所提供的值无效,
1-所需协议2-我的客户端应用程序使用“自定义标头”名称进行授权,但我不知道我必须将其放在此处