Skip to content
← Public packages

@kentcdodds/kody-connect-talk

Kent C. Dodds's Cloudflare Connect 2026 talk: why your agents' stuff needs a common house, and how Kody builds one on Cloudflare.

FollowForkOpen app

Files

router.ts

24 lines · 836 B · TypeScript
import { packageContext } from 'kody:runtime'
import { page } from './page.generated.ts'

/**
 * The deck is static: Vite builds it into dist/, which Kody serves under
 * `<appBasePath>/_assets/`. This handler only serves the presenter page (any
 * path, so `?mode=audience` and deep links work), pointing its URLs at the
 * asset mount.
 */
export default {
	async fetch(request: Request): Promise<Response> {
		if (request.method !== 'GET' && request.method !== 'HEAD') {
			return new Response('Method not allowed', { status: 405 })
		}
		const base = `${packageContext?.appBasePath ?? ''}/_assets/`
		const html = page.replaceAll('/__KODY_BASE__/', base)
		return new Response(request.method === 'HEAD' ? null : html, {
			headers: {
				'content-type': 'text/html; charset=utf-8',
				'cache-control': 'no-cache',
			},
		})
	},
}