Skip to content

Commit 9c86310

Browse files
committed
Enhance API diagnostics and handle ingress path detection
- Added logging for normalized pathname and resolved API root. - Included build version and installation kind in the console output. - Implemented a warning for detected ingress paths when the API root is '/api', indicating potential stale cached frontend bundles.
1 parent f3d4575 commit 9c86310

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

client/src/lib/api.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,25 @@ if (typeof window !== 'undefined') {
3434
// One-time diagnostic so users debugging "why does /api/... 404 in HA Ingress?" can confirm at a
3535
// glance which base the bundle is actually using. Cheap; runs once at module init.
3636
// eslint-disable-next-line no-console
37+
const normalizedPathname = window.location.pathname
38+
.replace(/\/+/g, '/')
39+
.replace(/\/+$/, '');
40+
const resolvedApiRoot = getApiRoot();
41+
const ingressPathDetected = /^\/api\/hassio_ingress\/[^/]+$/.test(normalizedPathname);
3742
console.info('[api] resolved API root', {
38-
apiRoot: getApiRoot(),
43+
apiRoot: resolvedApiRoot,
3944
baseUrl: import.meta.env.BASE_URL,
45+
buildVersion: import.meta.env.VITE_APP_BUILD_VERSION,
46+
installKind: import.meta.env.VITE_INSTALL_KIND,
47+
moduleUrl: import.meta.url,
4048
pathname: window.location.pathname,
49+
normalizedPathname,
4150
href: window.location.href,
4251
});
52+
if (ingressPathDetected && resolvedApiRoot === '/api') {
53+
// eslint-disable-next-line no-console
54+
console.warn('[api] ingress path detected but API root resolved to /api; stale cached frontend bundle is likely');
55+
}
4356
}
4457

4558
/**

0 commit comments

Comments
 (0)