The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard

vue項目中axios請求數據的時候請求失敗,出現跨域問題。

withCredentials 屬性

CORS請求默認不發送Cookie和HTTP認證信息。但是有的後臺要把Cookie發到服務器,要服務器同意,指定Access-Control-Allow-Credentials字段。

在axios的配置文件中配置withCredentials屬性,默認帶cookie給後臺,

import Axios from 'axios';

Axios.defaults.withCredentials=true;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章