Next.js (App Router) TypeScript
Snippet TypeScript untuk Next.js (App Router) yang menjawab request ke /pixel.gif dengan empty GIF, yang di-decode sekali saat 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',
},
});
}
Kami telah menjalankan snippet ini dan membandingkan byte yang dikembalikannya.
Periksa
curl -sI http://localhost:8080/pixel.gif
Situs resmi: Next.js (App Router)