fix(docker): harden frontend runtime config
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { backendBaseUrl, resolveBackendUrl } from "./runtime-config";
|
||||
import { backendBaseUrl, joinBackendPath, resolveBackendUrl } from "./runtime-config";
|
||||
|
||||
describe("resolveBackendUrl", () => {
|
||||
it("uses the runtime-injected backend URL", () => {
|
||||
@@ -15,3 +15,16 @@ describe("resolveBackendUrl", () => {
|
||||
expect(backendBaseUrl).toBe(import.meta.env.VITE_BACKEND_URL ?? "http://localhost:8787");
|
||||
});
|
||||
});
|
||||
|
||||
describe("joinBackendPath", () => {
|
||||
it.each([
|
||||
["", "/sessions/s1", "/sessions/s1"],
|
||||
["/", "/sessions/s1", "/sessions/s1"],
|
||||
["/api", "/sessions/s1", "/api/sessions/s1"],
|
||||
["/api/", "/sessions/s1", "/api/sessions/s1"],
|
||||
["https://example.test/api", "/sessions/s1", "https://example.test/api/sessions/s1"],
|
||||
["https://example.test/api/", "sessions/s1", "https://example.test/api/sessions/s1"],
|
||||
])("joins base %j and path %j", (base, path, expected) => {
|
||||
expect(joinBackendPath(base, path)).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user