emptygif
Sprache: Deutsch

Alle Sprachen und Frameworks

Next.js (App Router) TypeScript

Ein TypeScript-Snippet für Next.js (App Router), das Anfragen an /pixel.gif mit dem leeren GIF beantwortet, das einmal beim Start dekodiert wird.

Next.js (App Router) TypeScript

Installieren
npx create-next-app@latest
Datei
route.ts
Ausführen
npm run dev
// 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',
    },
  });
}

Wir haben dieses Snippet ausgeführt und die zurückgegebenen Bytes verglichen.

Prüfen

curl -sI http://localhost:8080/pixel.gif

Offizielle Website: Next.js (App Router)

Mehr in TypeScript