I am using serverless for creating and deploying my lambda functions. I am using Node.js - HTTP API
template from serverless. I have created few lambda functions and deployed them using command sls deploy
.
The functions were deployed successfully and I am able to query lambda function response using postman.
But, when I want to invoke same lambda function through my React webapp (using axios) it is throwing me A CORS Error
if I included any headers.
For ex. I want to send Authorization
token in header or Content-type
as json
in header. Any of this doesn't worked.
After this, I have added following headers in my lambda function response
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials": true,
After this, in AWS API Gateway console, I have configured CORS with wildcard origin and allowed All HTTP methods. After deploying this setup It's still doesn't worked.
I have also tried tweaking my serverless.yml
file but my bad it didn't worked either