Next.js (App Router) TypeScript
A TypeScript snippet for Next.js (App Router) that answers requests for /pixel.gif with the empty GIF, decoded once at startup.
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',
},
});
}
We ran this snippet and compared the bytes it returned.
Check it
curl -sI http://localhost:8080/pixel.gif
Official site: Next.js (App Router)