chadtmiller.com/knotless

Git hosted in your atproto account, on any stock PDS, fast enough for agents.

git clone knotless://chadtmiller.com/knotless

needs the knotless git helper. set it up

main
18 lines · 802 B Raw History
import type { Handle, HandleFetch } from '@sveltejs/kit/hooks';
import { KNOTLESS_SERVE } from '$app/env/private';

export const handle: Handle = ({ event, resolve }) =>
	resolve(event, { filterSerializedResponseHeaders: (name) => name === 'cache-control' });

/**
 * Asked of this site, `/_data` and `/xrpc` are asked of knotless-serve
 * directly, and with the global fetch: knotless-serve can have the same
 * origin as the site it fronts, which Kit's own would answer itself.
 */
export const handleFetch: HandleFetch = ({ event, request, fetch }) => {
	const url = new URL(request.url);
	if (url.origin === event.url.origin && /^\/(_data|xrpc)\//.test(url.pathname)) {
		return globalThis.fetch(new Request(`${KNOTLESS_SERVE}${url.pathname}${url.search}`, request));
	}
	return fetch(request);
};