Whenever I try to access serverless lambda function via POST through the browser I get the error
Response to preflight request doesn't pass access control check: No >'Access-Control-Allow-Origin' header is present on the requested resource.
When it is a /GET
it works fine I have read it is because it is not sending pre flight request. When I change it to POST
this is when it fails.
The command I am running:
sam local start-api
And my template.yaml is:
...
Resources:
PropertiesFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: target/service-0.0.1-SNAPSHOT.jar
Handler: com.aws.PropertiesHandler::handleRequest
Runtime: java8
Events:
PropertiesApi:
Type: Api
Properties:
Path: /properties
Method: post
...
How can I enable CORS on these endpoints?