我已經把tp5中的頭資訊和vue axios攜帶cookie資訊都開啟了,但通過axios異步呼叫時session還是無法取到值,各位大佬,請指教
uj5u.com熱心網友回復:
$response->header([
'Access-Control-Allow-Origin' => 'http://localhost:8080',
'Access-Control-Allow-Methods' => 'GET, POST, PATCH, PUT, DELETE',
'Access-Control-Allow-Headers' => 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With,token,uid,Cookie,authorization',
'Access-Control-Allow-Credentials' => 'true'
]);
如上 Credentials
axios中也需要開啟
axios.create({
baseURL: "http://localhost/", // url = base url + request url
withCredentials: true, // send cookies when cross-domain requests
timeout: 5000 // request timeout
})
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/50287.html
標籤:跨瀏覽器開發
