[英]In React Js Axios request getting CROS error
我將 Axios 用於 API,這是我的代碼。 我收到 CROS 錯誤。
axios({
method: 'GET',
headers : { 'Content-Type': 'application/json',
'Access-Control-Allow-Origin' : '*',
'mode': 'cors',
'Authorization':'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1N....'
},
url: baseURL,
}).then(function (response) {
console.log(response);
});
您需要從后端服務啟用 CORS。 從圖中可以清楚地看出,您的前端在 localhost 的 3000 端口上運行,而您的后端或 api 服務在 localhost 的 8000 端口上運行。 因此,從您的后端或 api 服務啟用 CORS。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.