I've developed an AWS function with .net core, it's been deployed to AWS and I can call it from Postman and seems everything's ok, but when I try to call it from a react application with Axios library I get this error:
(index):1 Access to XMLHttpRequest at 'https://awsfunctionurl/api/Organisations' from origin 'http://localhost:3001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
here is the code to call the API:
const response: Response = await axios.get(url,{
headers:{
"content-type": "application/json; charset=utf-8",
"Authorization": `Bearer ${accesToken}`
},
})
When I remove Authorization header it starts working!