Reputation: 1
I tried by configuring 'Enable CORS' in API Gateway and set all the required headers as well. In the Lambda function, I set headers like Access-Control-Allow-Origin, Access-Control-Allow-Methods, Access-Control-Allow-Headers?
Preflight request hasnt been sent to the Lambda function from API Gateway. Is there anything that I need to check and configure?
Kindly help me out. Thanks in advance
def lambda_handler(event, context):
return {
"statusCode": "200",
"headers": {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "*",
"Access-Control-Allow-Headers": "*",
},
"body": json.dumps({"test": "123"})
}
Upvotes: 0
Views: 687
Reputation: 9462
Have you configured API Gateway to use Lambda Proxy Integration? If you want to have your lambda set the headers, you should do this.
Essentially, you either let your lambda add the necessary headers, as you appear to want to do in this example, or you let API Gateway add them. To have the lambda add them you need to enable Lambda Proxy Integration.
See
Upvotes: 1