Open Pavel910 opened 5 years ago
@Pavel910 yeah totally agreed with you. This component is meant to be a lower level component, so it should eventually support all these options. So PR is welcome 😊
Honestly, we need to refactor the entire domain component cause there's a lot of CloudFront stuff happening in there that should be included here. But this task turned out to be more complex than I thought as it also affects the website
and cdn
components. But overall, the cloudfront component is where we want to handle all the cloudfront provisioning stuff.
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:
1) it is not forwarding several headers that are important for my API (
Accept
andAccept-Language
), that behavior is documented in official AWS docs.2) 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:@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! 🍻