diff --git a/hassio/src/hassio-router.ts b/hassio/src/hassio-router.ts index 4118e82387..4e71ca7ca6 100644 --- a/hassio/src/hassio-router.ts +++ b/hassio/src/hassio-router.ts @@ -23,7 +23,7 @@ class HassioRouter extends HassRouterPage { protected routerOptions: RouterOptions = { // Hass.io has a page with tabs, so we route all non-matching routes to it. defaultPage: "dashboard", - initialLoad: () => this._fetchData(), + initialLoad: () => this._redirectIngress(), showLoading: true, routes: { dashboard: { @@ -50,7 +50,13 @@ class HassioRouter extends HassRouterPage { protected updatePageEl(el) { // the tabs page does its own routing so needs full route. - const route = el.nodeName === "HASSIO-PANEL" ? this.route : this.routeTail; + const hassioPanel = el.nodeName === "HASSIO-PANEL"; + const route = hassioPanel ? this.route : this.routeTail; + + if (hassioPanel && this.panel.config?.ingress) { + this._redirectIngress(); + return; + } el.hass = this.hass; el.narrow = this.narrow; @@ -63,15 +69,14 @@ class HassioRouter extends HassRouterPage { } } - private async _fetchData() { + private async _redirectIngress() { if (this.panel.config && this.panel.config.ingress) { - this._redirectIngress(this.panel.config.ingress); + this.route = { + prefix: "/hassio", + path: `/ingress/${this.panel.config.ingress}`, + }; } } - - private _redirectIngress(addonSlug: string) { - this.route = { prefix: "/hassio", path: `/ingress/${addonSlug}` }; - } } declare global {