1. 程式人生 > >跨域問題,Request header field XXXXX is not allowed by Access-Control-Allow-Headers 的問題

跨域問題,Request header field XXXXX is not allowed by Access-Control-Allow-Headers 的問題

允許 span 一個 cti requested action soa ted tom

<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE,OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With,SOAPAction" />
</customHeaders>
</httpProtocol>

瀏覽器為了安全起見,會先發送一個 options 請求,確保請求發送是安全的,一般 POST DELETE PUT 等請求都會修改服務器資源,所以瀏覽器會先發一個請求,問問服務器是否會正確(允許)請求,若不支持 options 請求,請求也會死掉

跨域問題,Request header field XXXXX is not allowed by Access-Control-Allow-Headers 的問題