diff --git a/packages/remote-control-server/src/config.ts b/packages/remote-control-server/src/config.ts index f67771070..39ba2c400 100644 --- a/packages/remote-control-server/src/config.ts +++ b/packages/remote-control-server/src/config.ts @@ -18,6 +18,6 @@ export const config = { } as const; export function getBaseUrl(): string { - if (config.baseUrl) return config.baseUrl; - return `http://localhost:${config.port}`; + const url = config.baseUrl || `http://localhost:${config.port}`; + return url.replace(/\/+$/, ""); } diff --git a/packages/remote-control-server/src/index.ts b/packages/remote-control-server/src/index.ts index 44aaf3c0d..cd9991285 100644 --- a/packages/remote-control-server/src/index.ts +++ b/packages/remote-control-server/src/index.ts @@ -33,6 +33,17 @@ const app = new Hono(); // Middleware app.use("*", logger()); +app.use("*", async (c, next) => { + // Normalize double slashes in path (e.g. //v1/environments/bridge → /v1/environments/bridge) + const path = new URL(c.req.url).pathname; + if (path.includes("//")) { + const normalized = path.replace(/\/+/g, "/"); + const url = new URL(c.req.url); + url.pathname = normalized; + return app.fetch(new Request(url.toString(), c.req.raw)); + } + await next(); +}); app.use("/web/*", cors()); // Health check