INNER CODE UNIT · TypeScript
dispatchPath
colyseus/colyseus · packages/admin/src-backend/index.ts:559
const dispatchPath = mount && !isApi ? ctx.uiPath + url : url;
// Canonicalize the bare index URL onto its trailing slash. 302, not
// 301 — browsers cache 301s across dev-server remounts.
const original = (r.originalUrl ?? raw).split('?')[0]!;
const bare = mount ? url === '/' && !original.endsWith('/') : url === ctx.uiPath;
if (method === 'GET' && bare) {
res.writeHead(302, { location: `${original}/${query}` });
res.end();
return;
}
const dispatch = (handler: (rq: any, rs: any) => Promise<void>) => {
const headers: typeof req.headers = { ...req.headers };
// Internal mount-coordinate headers — always ours, never the client's
delete headers['x-colyseus-admin-base'];
delete headers['x-colyseus-admin-api'];
if (mount) {