Hello,
I’m trying to connect to my Rest API (a lambda function + serverless), but I’m getting this cors error in my front web app side:
Access to fetch at 'https://apigw.xxx from origin ‘http://localhost:3002’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.
I tried to add the cors config in my serverless.yml file like that:
functions:
test:
handler: "./src/functions/test/handler.main"
events:
- httpApi:
path: /test
method: post
cors:
origin: '*'
maxAge: 86400
I also added the headers to the returned response, but I’m still getting the same error.
Could anyone help me fix that?
Thanks