1. 程式人生 > >No 'Access-Control-Allow-Origin' header is present on the requested resource

No 'Access-Control-Allow-Origin' header is present on the requested resource

請求 ted -c ref aliyun 跨域 sent res 服務器的響應

一、現象

ajax調用請求後,前端提示收到這個錯誤

No ‘Access-Control-Allow-Origin‘ header is present on the requested resource

二、原因

這是一個典型的跨域請求失敗的例子。

三、解決

服務器的響應消息中增加頭字段即可。

rsp.addHeader("Access-Control-Allow-Origin", "*");

四、擴展

更多的關於CORS的內容可以學習這篇文章:

https://yq.aliyun.com/articles/69313

No 'Access-Control-Allow-Origin' header is present on the requested resource