CodeGenieApp / CodeGenieApp/serverless-express
serverless-express callback request
- Vorherrschende Sprache
- JavaScript
- Sterne
- 5.3k
- Forks
- 676
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
s3(image) + cloudfront + lambda@edge
I'm only processing image requests from users authenticated with vanilla http.
*** vanilla-http
xxx.cloudfront.net/image.png
const authUtil = require("./middlewares/auth");
exports.handler = (event, context, callback) => {
const { request, response } = event.Records[0].cf;
result = authUtil(request);
if(result.success) {
callback(null, request);
}
};
// This works well. (image download)
serverless-express
router.get('/:file', async (req, res) => {
const { event, context } = getCurrentInvoke()
const eventRequest = event.Records[0].cf.request;
res.json(eventRequest)
});
// not working
***
{"clientIp":"000.000.000.000","headers":{"host":[{"key":"Host","value":"dl78camcjz7wt.cloudfront.net"}],"user-agent":[{"key":"User-Agent","value":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36"}],"
***
I need help to solve this problem.
Beitragsleitfaden
Rechercherichtung
Start with the Lambda@Edge handler and the Express route shown in the issue, then inspect how getCurrentInvoke() exposes event and context in serverless-express. Compare the working vanilla-http callback path with the route's response handling and reproduce the request using the provided CloudFront event shape. Done means the route reliably returns the expected request data for an image request.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- aws, express, javascript, node.js
- Bereich
- api, backend, cloud
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100