1. 程式人生 > >axios跨域訪問錯誤(vue.js)

axios跨域訪問錯誤(vue.js)

文章來自:原始碼線上https://www.shengli.me/javascript/287.html

 

1、假如訪問的介面地址為 http://www.test.com/apis/index.php  (php api 介面)

2、而開發地址為http://127.0.0.1:8080,當axios發起請求時,出現如下錯誤:

Failed to load http://www.test.com/apis/index.php?&act=login: The value of the 'Access-Control-Allow-Origin' headerin the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://127.0.0.1:8080' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.