問題描述:
登陸帳號的時候,提示跨域錯誤
故障現象:跨域
緣由分析:
一、跨域問題,這邊都是由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