HAOS Add-on: Ingress-Pfad-Fix im Web UI

Fetches verwendeten absolute Pfade (/api/...) → gingen an HA REST API statt Add-on.
Hinter HA Ingress-Proxy muss der Pfad relativ zur Seiten-URL sein.
Fix: BASE = window.location.href + "./" → apiUrl() für alle fetch-Aufrufe.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
retr0
2026-04-24 23:07:15 +02:00
parent c146df2ec9
commit e2d67f3447
+8 -4
View File
@@ -379,6 +379,10 @@ let currentConfig = {};
let inverterList = {};
let refreshTimer = null;
// Basis-URL relativ zur aktuellen Seite (funktioniert hinter HA Ingress-Proxy)
const BASE = new URL("./", window.location.href).pathname;
function apiUrl(path) { return BASE + path; }
async function fetchJSON(url, opts) {
const r = await fetch(url, opts);
if (!r.ok) throw new Error(`HTTP ${r.status}`);
@@ -408,7 +412,7 @@ function switchTab(name) {
// ── Live data ──
async function refreshData() {
try {
const d = await fetchJSON("/api/data");
const d = await fetchJSON(apiUrl("api/data"));
updateStatus(d.modbus_ok, d.mqtt_ok);
updateSubtitle(d);
updateInfoRow(d);
@@ -479,7 +483,7 @@ function stopRefresh() {
// ── Config ──
async function loadConfig() {
try {
currentConfig = await fetchJSON("/api/config");
currentConfig = await fetchJSON(apiUrl("api/config"));
fillForm(currentConfig);
} catch (e) {
showToast("Konfiguration konnte nicht geladen werden", "err");
@@ -488,7 +492,7 @@ async function loadConfig() {
async function loadInverters() {
try {
inverterList = await fetchJSON("/api/inverters");
inverterList = await fetchJSON(apiUrl("api/inverters"));
buildInverterGrid(inverterList, currentConfig.inverter_model);
} catch (e) {}
}
@@ -541,7 +545,7 @@ async function saveConfig(e) {
};
try {
await fetchJSON("/api/config", {
await fetchJSON(apiUrl("api/config"), {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),