This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / web / src / hooks.server.ts
1.2 kB 30 lines
1import type { Handle } from "@sveltejs/kit"; 2 3type BobbinService = { 4 fetch(request: Request): Promise<Response>; 5}; 6 7export const handle: Handle = async ({ event, resolve }) => { 8 // Keep bobbin off the public network. In Cloudflare this is a Worker 9 // service binding; the browser only ever sees the web origin. 10 if (event.url.pathname === "/xrpc" || event.url.pathname.startsWith("/xrpc/")) { 11 const bobbin = (event.platform?.env as { BOBBIN?: BobbinService } | undefined)?.BOBBIN; 12 if (bobbin) { 13 const upstream = new URL(event.request.url); 14 upstream.hostname = "bobbin.internal"; 15 return bobbin.fetch(new Request(upstream, event.request)); 16 } 17 } 18 19 return resolve(event, { 20 // sveltekit blocks atcute fetch handler from reading headers 21 // because it assumes backend APIs might return sensitive headers. 22 // this happens when during CSR we run a fetch that was the same 23 // as one ran during SSR, so sveltekit tries to give that fetch 24 // the data we already had. 25 // so we allow these headers to have atcute function properly. 26 filterSerializedResponseHeaders(name) { 27 return name === "content-type" || name === "content-length"; 28 } 29 }); 30};