Netlify Edge Functions TypeScript
Uno snippet TypeScript per Netlify Edge Functions che risponde alle richieste a /pixel.gif con la GIF vuota, decodificata una sola volta all'avvio.
Netlify Edge Functions TypeScript
// netlify/edge-functions/pixel.ts (runs on Deno at the edge)
import type { Config } from '@netlify/edge-functions';
const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));
export default () =>
new Response(GIF, {
headers: {
'Content-Type': 'image/gif',
'Content-Length': String(GIF.length),
'Cache-Control': 'no-store',
},
});
export const config: Config = { path: '/pixel.gif' };
Abbiamo eseguito questo snippet e confrontato i byte che ha restituito.
Verifica
curl -sI http://localhost:8080/pixel.gif
Sito ufficiale: Netlify Edge Functions