I am trying to allow requests to my Lambda Function URL only from my specific URL and only for POST methods.
Here is my Lambda Function URL configuration:
Here is the Lambda function content:
import json
def lambda_handler(event, context):
# TODO implement
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!!')
}
Problems:
I tried 'Access-Control-Allow-Origin': '*' as well but it didn't work.
What am I doing wrong here?
After some trial and error, I found the solution.
As seen in the screenshot below, I added the same headers to Expose Headers in Lambda Function URL config. This way, "No 'Access-Control-Allow-Origin' header is present on the requested resource." error is gone, since they are now exposed to the requester.
I'm still open to suggestions about whether I should change those allowed and exposed headers, if all is not required.
Thanks.