mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25:51 +00:00
fix: 修复服务器两个 / 的问题
This commit is contained in:
@@ -18,6 +18,6 @@ export const config = {
|
|||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export function getBaseUrl(): string {
|
export function getBaseUrl(): string {
|
||||||
if (config.baseUrl) return config.baseUrl;
|
const url = config.baseUrl || `http://localhost:${config.port}`;
|
||||||
return `http://localhost:${config.port}`;
|
return url.replace(/\/+$/, "");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,17 @@ const app = new Hono();
|
|||||||
|
|
||||||
// Middleware
|
// Middleware
|
||||||
app.use("*", logger());
|
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());
|
app.use("/web/*", cors());
|
||||||
|
|
||||||
// Health check
|
// Health check
|
||||||
|
|||||||
Reference in New Issue
Block a user