fix: resolve diagnostic paths under the base path prefix and tolerate health-style ping responses

This commit is contained in:
2026-08-13 20:58:10 +02:00
parent 3a3efc3285
commit 9d7e9a05b7
3 changed files with 22 additions and 4 deletions
+4 -1
View File
@@ -423,7 +423,10 @@ export function validateOperationalWorkspace(workspace: unknown): WorkspaceV3 {
export function resolveDiagnosticUrl(baseUrl: string, path: string): URL {
if (!isOriginRelativeDiagnosticPath(path)) throw new Error("Diagnostic path must remain on the configured origin");
const base = new URL(baseUrl);
const resolved = new URL(path, base);
// Resolve the origin-relative path beneath the configured base path (e.g. `/dwh/`), not the
// origin root: a leading slash must append to the base path instead of resetting it.
const basePath = base.pathname.endsWith("/") ? base.pathname : `${base.pathname}/`;
const resolved = new URL(`${basePath}${path.replace(/^\/+/, "")}`, base.origin);
if (resolved.origin !== base.origin) throw new Error("Diagnostic URL must remain on the configured origin");
return resolved;
}