Next.js (App Router) TypeScript
/pixel.gif へのリクエストに空の GIF を返す、Next.js (App Router) 用の TypeScript スニペット。GIF は起動時に一度だけデコードします。
Next.js (App Router) TypeScript
// app/pixel.gif/route.ts
const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));
export function GET() {
return new Response(GIF, {
headers: {
'Content-Type': 'image/gif',
'Content-Length': String(GIF.length),
'Cache-Control': 'no-store',
},
});
}
このスニペットは実行し、返されたバイト列を照合しました。
確認
curl -sI http://localhost:8080/pixel.gif