A live bird collage card for your Home Assistant dashboard.
Fix 405 on review writes: normalize ingress base to token mount (#29)
Adam Oberleydae3bc5699e3
diff --git a/dist/habird-card.js b/dist/habird-card.jsindex ec55a178..24d891a0 100644--- a/dist/habird-card.js+++ b/dist/habird-card.js@@ -138,8 +138,14 @@ function runHABirdApp(__root, __shell, __cardConfig, __imgBase) {// prefix is stable across installs.return sup('GET', 'addons/db21ed7f_birdnet-go/info');}).then(function (info) {- if (!info.ingress || !info.ingress_url) throw new Error('add-on has no ingress');- var base = String(info.ingress_url).replace(/\/+$/, '');+ if (!info.ingress || !(info.ingress_url || info.ingress_entry)) throw new Error('add-on has no ingress');+ // ingress_url may include the add-on's landing subpath (this one+ // declares ingress_entry: ui/dashboard) - POSTing under that hits+ // the UI's GET-only catch-all and 405s. The API lives at the bare+ // token mount, so strip everything after the token.+ var raw = String(info.ingress_url || info.ingress_entry);+ var m = raw.match(/^(\/api\/hassio_ingress\/[^\/]+)/);+ var base = m ? m[1] : raw.replace(/\/+$/, '');var session = null;function newSession() {return sup('POST', 'ingress/session').then(function (r) {diff --git a/homeassistant/www/apt.js b/homeassistant/www/apt.jsindex e1e66cce..eebaec6c 100644--- a/homeassistant/www/apt.js+++ b/homeassistant/www/apt.js@@ -103,8 +103,14 @@// prefix is stable across installs.return sup('GET', 'addons/db21ed7f_birdnet-go/info');}).then(function (info) {- if (!info.ingress || !info.ingress_url) throw new Error('add-on has no ingress');- var base = String(info.ingress_url).replace(/\/+$/, '');+ if (!info.ingress || !(info.ingress_url || info.ingress_entry)) throw new Error('add-on has no ingress');+ // ingress_url may include the add-on's landing subpath (this one+ // declares ingress_entry: ui/dashboard) - POSTing under that hits+ // the UI's GET-only catch-all and 405s. The API lives at the bare+ // token mount, so strip everything after the token.+ var raw = String(info.ingress_url || info.ingress_entry);+ var m = raw.match(/^(\/api\/hassio_ingress\/[^\/]+)/);+ var base = m ? m[1] : raw.replace(/\/+$/, '');var session = null;function newSession() {return sup('POST', 'ingress/session').then(function (r) {