私はLAMBDA_PROXY統合要求タイプのAPIゲートウェイを持っています。 Lambdaでcontext.succeedを呼び出すと、応答ヘッダーがコード302とともに返されます(下図参照)。しかし、私は500と404のエラーを処理したい、私はこれまでのところ確信している唯一のことは、私が誤って502のバッドゲートウェイを取得しているエラーを返すことです。私の文脈に何が問題なのですか?ここでAWS APIゲートウェイの応答が502の "Bad Gateway"を生成する
を使用すると、ラムダ関数(またはcontext.fail)内に例外をスローした場合、何かがあなたのバックエンドとリターンと間違っていたかのように、API Gatewayはそれを読み
const handler = (event, context) => {
//event consists of hard coded values right now
getUrl(event.queryStringParameters)
.then((result) => {
const parsed = JSON.parse(result);
let url;
//handle error message returned in response
if (parsed.error) {
let error = {
statusCode: 404,
body: new Error(parsed.error)
}
return context.fail(error);
} else {
url = parsed.source || parsed.picture;
return context.succeed({
statusCode: 302,
headers: {
Location : url
}
});
}
});
};
私は今、それを見て感謝します、ありがとう – jmcgui05