Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

devProxy.ts

17 lines780 Bytes

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 = ["/api", "/oauth", "/.well-known", "/ws"] as const;
12​
13export function isDevProxiedPath(pathname: string): boolean {
14 return DEV_PROXIED_PATH_PREFIXES.some(
15 (prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`),
16 );