CodeGenieApp / CodeGenieApp/serverless-express
Support for Cloudfront as event source
- Dominant language
- JavaScript
- Stars
- 5.3k
- Forks
- 674
- PR merge metrics
- No merged PRs in 30d
Description
I've got requests passing through a Cloudfront distribution directly to a lambda, no cache, passing all request headers with it. I'm using this approach because API Gateway and ALB are both overkill for my use-case, simply need a public endpoint with custom domain compatibility, hence Cloudfront.
Issue is that this library produces a `Unable to determine event source based on event` error in this setup. Having a look at the code it seems [here](https://github.com/vendia/serverless-express/blob/75cfbffeb3fd030695b9587a75300c7b8012ac6a/src/event-sources/utils.js#L70) that there is no conditional to detect this circumstance.
Since I'm passing all headers directly through Cloudfront, I assume that the event in this case looks a lot like it came directly from the client, rather than something triggered through another cloud service. This seems to me perhaps as a valid default case to design for in this library, in the absence of any other forwarders?
Contributor guide
Research direction
Start at src/event-sources/utils.js around line 70, where event-source detection currently fails for the described CloudFront-to-Lambda request. Reproduce or inspect an event with CloudFront forwarding all headers, then define the detection behavior needed for this direct endpoint case. Done means the event is accepted without the "Unable to determine event source" error and the relevant behavior is covered by tests if the repository provides them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, express, javascript, node.js
- Domain
- api, backend, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100