1/**
2 * Backend paths the web dev server proxies in single-origin browser dev.
3 *
4 * Two consumers must agree on this list: the Vite proxy map
5 * (apps/web/vite.config.ts) that forwards these to the backend, and the
6 * server's dev catch-all (apps/server/src/http.ts) that 404s them instead of
7 * redirecting back to Vite. Drift is silent and nasty in both directions — a
8 * prefix only Vite knows gets answered with index.html; a prefix only the
9 * server knows redirect-loops through the proxy.
10 */
11export const DEV_PROXIED_PATH_PREFIXES = [
12 "/api",
13 "/oauth",
14 "/.well-known",
15 "/ws",
16 "/mcp",
17 "/environments",
18] as const;
19
20/**
21 * Prefixes the proxy must forward with the browser's own Host. MCP OAuth
22 * derives its issuer and resource URLs from the request, and a client
23 * rejects metadata naming a different origin than the one it fetched. The
24 * server accepts a cookie session on `/ws` only when the page's Origin matches
25 * the Host it sees, so whatever origin the page was opened on keeps working.
26 */
27export const DEV_PROXIED_ORIGIN_PRESERVING_PREFIXES: ReadonlySet<string> = new Set([
28 "/oauth",
29 "/.well-known",
30 "/mcp",
31 "/ws",
32 "/environments",
33]);
34
35export function isDevProxiedPath(pathname: string): boolean {
36 return DEV_PROXIED_PATH_PREFIXES.some(
37 (prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`),
38 );
39}