AWS Lambda (Node.js) JavaScript
/pixel.gif 요청에 빈 GIF로 응답하는 AWS Lambda (Node.js)용 JavaScript 스니펫입니다. GIF는 시작할 때 한 번만 디코딩합니다.
AWS Lambda (Node.js) JavaScript
// index.mjs - behind an API Gateway HTTP API route "GET /pixel.gif" or a function URL.
// Binary bodies travel base64-encoded, so the GIF stays in base64 here.
const GIF_BASE64 = 'R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
export const handler = async () => ({
statusCode: 200,
headers: { 'Content-Type': 'image/gif', 'Cache-Control': 'no-store' },
body: GIF_BASE64,
isBase64Encoded: true,
});
이 스니펫은 실행해 보고, 반환된 바이트를 비교했습니다.
확인
curl -sI http://localhost:8080/pixel.gif