-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
Description:
When setting up an API Gateway with {proxy+} integration through SAM, having a required API key prevents the CORS definition from properly responding to OPTIONS requests, since they require an API key as well.
Steps to reproduce the issue:
- Define an Api that requires an API key:
Resources:
BasicAWSApiGateway:
Type: AWS::Serverless::Api
Properties:
StageName: !Ref Environment
Auth:
ApiKeyRequired: true
Cors: "'*'"
DefinitionBody:
swagger: "2.0.0"
info:
version: 1.0.0
paths:
/{proxy+}:
x-amazon-apigateway-any-method:
produces:
- application/json
parameters:
- in: path
name: proxy
required: true
type: string
x-amazon-apigateway-integration:
uri: !Sub "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${LambdaName}-${Environment}/invocations"
httpMethod: POST
type: aws_proxy
passthroughBehavior: when_no_match
credentials: !GetAtt ApiGatewayExecutionRole.Arn
Observed result:
The OPTIONS
method in API Gateway requires an API Key, blocking CORS since browsers don't add a x-api-key
header.
Expected result:
The OPTIONS
method should not require an API Key.
codepuzzle, jrowny, pisaacs, MartinJaskulla, FutureArchitect-takeda1874 and 21 moresimoroma and jorgetovar