-
Notifications
You must be signed in to change notification settings - Fork 12
Description
So today I ran into a problem where I'm deploying an Apollo Server for my GraphQL API and CloudFront is causing a few problems:
-
it is not forwarding several headers that are important for my API (
AcceptandAccept-Language), that behavior is documented in official AWS docs. -
by default POST requests are not allowed, and GraphQL runs on POST most of the time.
Proposed solution
Introduce more options to @serverless/aws-cloudfront component to allow headers and methods customization. Here is an example:
distribution:
component: '@serverless/aws-cloudfront'
inputs:
origins:
- url: ${api.url}
pathPatterns:
"*":
ttl: 0
forward:
headers: ["Accept", "Accept-Language"]
allowedMethods: ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]
@eahefnawy This is related to the issue in aws-api-gateway repo. I know this looks like too many options, but since CloudFront is a quirky CDN, I can't seem to find a cleaner solution to the problem.
I'd be glad to send a PR, but I want to hear your opinion on this first.
Cheers! 🍻