I used Axios for API, here is my code. I am getting CROS error.
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); });
Advertisement
Answer
You’ll need to enable CORS from your back-end service. From the image, it is clear that your front-end in running on localhost on port 3000 whereas your back-end or api service is running on port 8000 on localhost. So, enable CORS from your back-end or api serivce.