问题描述:
登陆帐号的时候,提示跨域错误
故障现象:跨域
缘由分析:
一、跨域问题,这边都是由NG处理,NG原先已经配置了跨域处理
二、根据截图分析,ng 容许跨域的Header少了Authorization,NG的header添加Authorization,问题解决ide
if ($request_method = OPTIONS ) { return 200; } add_header Access-Control-Allow-Origin "*"; add_header Access-Control-Allow-Methods GET,POST,PUT,OPTIONS,DELETE,PATCH; add_header Access-Control-Allow-Credentials true; add_header Access-Control-Allow-Headers DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,userId,token,vcode,Authorization; add_header Access-Control-Max-Age 1728000;
跨域问题处理总结:
一、跨域问题不能重复处理,要么在ng处理,要么在代码层处理
二、根据错误提示,缺乏什么header头,在配置文件中增长
三、Access-Control-Allow-Origin 使用"*"、单域名、多域名 都行。
四、Access-Control-Allow-Methods 方法也须要能匹配上code