fix(version): move the finer geo state to the admin status

geoLookup and geoProviderChosen on the public /api/version added one
more way to tell instances apart. They now live on /api/admin/status
(requireAdmin, cookie only) as geo { lookup, providerChosen,
providerHost }, which both admin status views read. offlineGeoEnabled
and geoProviderHost stay public as before.
This commit is contained in:
Marc-André Bombeck committed 2026-10-09 10:44:18 +02:00
1 parent 0ea8d929d2
commit 470ddeedc4
11 files changed
+135 -128

No files matched your search

+19 -2
View File
@@ -9,8 +9,6 @@ const resolveGeoProviderHostMock = vi.fn(() => "ipwho.is");
vi.mock("@/lib/geo", () => ({
offlineGeoReady: () => offlineGeoReadyMock(),
resolveGeoProviderHost: () => resolveGeoProviderHostMock(),
geoLookupMode: () => (offlineGeoReadyMock() ? "offline" : "online"),
geoProviderChosen: () => false,
}));
import { GET } from "../route";
@@ -108,4 +106,23 @@ describe("GET /api/version", () => {
const body = (await response.json()) as VersionEnvelope;
expect(body.data.geoProviderHost).toBe("ip-api.com");
});
it("keeps the finer geo state off the public answer", async () => {
// Lookup mode and whether the operator chose the provider are admin-only
// (`/api/admin/status`); the public route would only add a way to tell
// instances apart.
const response = await (GET as unknown as () => Promise<Response>)();
const body = (await response.json()) as { data: Record<string, unknown> };
expect(Object.keys(body.data).sort()).toEqual([
"buildSha",
"builtAt",
"changelog",
"docs",
"geoProviderHost",
"license",
"offlineGeoEnabled",
"repository",
"version",
]);
});
});