axios cors error when server response Access-Control-Allow-Origin header has set to allow all

Viewed 22

I am learning react. I run into a strange problem. In react, it makes an HTTP GET call to backend API (AWS Apigateway + lambda). I got a CORS error response. I tested my backend API with Postman. The Access-Control-Allow-Origin has been set to *. What is wrong here? Here is my code React

const { data } = await axios(url, {
  method: 'GET',
  mode: 'no-cors',
  crossdomain: true,
  headers: {
    'Access-Control-Allow-Origin': '*',
    'Content-Type': 'application/json'
   },
    withCredentials: false
   });

postman response

enter image description here

enter image description here

0 Answers
Related