Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
/**
* Pure helpers for the embedded-service reverse proxy path handling.
*
* Kept dependency-free so the behavior can be unit-tested without pulling in
* the registry / DB / htmlRewriter that `reverseProxy.ts` imports.
*/
/**
* Map the `[[...path]]` catch-all segments to an upstream request path.
*
* The segment-less panel root (`/embed/`, matched only because the route is an
* OPTIONAL catch-all — #6205) yields an empty segment array, which must map to
* `"/"` so the embedded service serves its index page instead of `/undefined`.
*
* @param pathSegments The catch-all segments, e.g. `["ui", "index.html"]` or `[]`.
*/
export function toUpstreamPath(pathSegments: string[]): string {
return pathSegments.length > 0 ? "/" + pathSegments.join("/") : "/";
}