CodeGenieApp / CodeGenieApp/serverless-express

serverless-express callback request

オープン
#430 コメント 4 件 リアクション 2 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
5.3k
フォーク
676
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Issue に示されている Lambda@Edge handler と Express route から始め、serverless-express で getCurrentInvoke() が event と context をどのように公開しているかを確認します。動作する vanilla-http callback path と route の response handling を比較し、提供されている CloudFront event shape を使ってリクエストを再現します。画像リクエストに対して route が期待される request data を確実に返すようになれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
aws, express, javascript, node.js
領域
api, backend, cloud
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。