-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
area/local/start-apisam local start-api commandsam local start-api commandpriority/2-importanttype/bug
Description
Description
According to https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#cors-configuration CORS configuration strings should have an extra pair of quotes like this:
Cors:
AllowMethods: "'OPTIONS,GET,POST,DELETE'"
AllowHeaders: "'X-Forwarded-For'"
AllowOrigin: "'*'"
Running sam local start-api with a template containing the above gives me: Error: The method 'OPTIONS is not a valid CORS method. (notice the dangling quote).
Steps to reproduce
Add the Cors configuration above to an API definition. Run sam local start-api.
Sample template:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
HelloApi:
Type: AWS::Serverless::Api
Properties:
StageName: prod
Cors:
AllowOrigin: "'*'"
AllowMethods: "'OPTIONS,HEAD,GET,PUT,POST'"
AllowHeaders: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello-world/
Handler: app.lambdaHandler
Runtime: nodejs10.x
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get
RestApiId:
Ref: HelloApi
Observed result
$ sam --debug local start-api
Error: The method 'OPTIONS is not a valid CORS method
If I remove the extra singe quotes in AllowMethods, sam local start-api works as expected, but then I cannot deploy the template.
Expected result
Expected a running API with CORS enabled.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: macOS 10.14.6
sam --version: SAM CLI, version 0.21.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/local/start-apisam local start-api commandsam local start-api commandpriority/2-importanttype/bug