React Router (framework mode, ex-Remix) TypeScript
/pixel.gif へのリクエストに空の GIF を返す、React Router (framework mode, ex-Remix) 用の TypeScript スニペット。GIF は起動時に一度だけデコードします。
React Router (framework mode, ex-Remix) TypeScript
// app/routes.ts: route('/pixel.gif', 'routes/pixel.ts')
// app/routes/pixel.ts - a resource route: a loader and no default export.
const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));
export function loader() {
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
公式サイト: React Router (framework mode, ex-Remix)