I have created an API endpoint with Serverless(serverless.com) which I expose through API Gateway. I\'m getting following error though I have enabled CORS from the
You need to enable CORS for all the methods. Means, you need to add below three headers for all your methods
"headers": {
"Access-Control-Allow-Origin": {
"type": "string"
},
"Access-Control-Allow-Methods": {
"type": "string"
},
"Access-Control-Allow-Headers": {
"type": "string"
}
}
It is tedious task to add these headers to all your methods in JSON.
Created a utility in Java which automatically adds these headers to Swagger JSON. You can run it before importing it to API Gateway and import the output JSON which has CORS enabled in all the methods
https://github.com/anandlalvb/SwaggerToAPIGateway
I hope this utility may help anyone looking for this to do it easily.