diff --git a/maintainerr/rootfs/etc/nginx/servers/ingress.conf b/maintainerr/rootfs/etc/nginx/servers/ingress.conf index 0c793020f..7cb4622b1 100644 --- a/maintainerr/rootfs/etc/nginx/servers/ingress.conf +++ b/maintainerr/rootfs/etc/nginx/servers/ingress.conf @@ -7,7 +7,6 @@ server { gzip_static off; client_max_body_size 0; - # Based on https://docs.maintainerr.info/ReverseProxy/#nginx-subdomain location / { set $app '%%ingress_entry%%'; @@ -23,7 +22,6 @@ server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header Accept-Encoding ""; proxy_read_timeout 90; add_header X-Frame-Options "SAMEORIGIN"; add_header 'Referrer-Policy' 'no-referrer'; @@ -31,31 +29,5 @@ server { # Redirect location headers absolute_redirect off; proxy_redirect / $app/; - - # Sub filters to rewrite URLs in responses - sub_filter_once off; - sub_filter_types *; - - # HTML attribute rewrites - sub_filter 'href="/"' 'href="%%ingress_entry%%/"'; - sub_filter 'src="/' 'src="%%ingress_entry%%/'; - sub_filter 'action="/' 'action="%%ingress_entry%%/'; - - # API path rewrites - sub_filter '"/api' '"%%ingress_entry%%/api'; - sub_filter '`/api' '`%%ingress_entry%%/api'; - sub_filter "'/api" "'%%ingress_entry%%/api"; - - # Vite asset rewrites - sub_filter '"/assets' '"%%ingress_entry%%/assets'; - sub_filter '`/assets' '`%%ingress_entry%%/assets'; - sub_filter "'/assets" "'%%ingress_entry%%/assets"; - - # Favicon and static files - sub_filter '"/favicon' '"%%ingress_entry%%/favicon'; - sub_filter '"/logo' '"%%ingress_entry%%/logo'; - - # Root path references in JavaScript - sub_filter '"\/"' '"%%ingress_entry%%\/"'; } } diff --git a/maintainerr/rootfs/ha_entrypoint.sh b/maintainerr/rootfs/ha_entrypoint.sh index a5c645736..36aaf20aa 100755 --- a/maintainerr/rootfs/ha_entrypoint.sh +++ b/maintainerr/rootfs/ha_entrypoint.sh @@ -65,6 +65,25 @@ if [ ! -f "$DATA_DIR/.initialized" ]; then fi export DATA_DIR +# ─── Inject ingress base path into the built UI files ───────────────────────── +# The upstream Maintainerr Vite build embeds /__PATH_PREFIX__ as a placeholder +# for the base URL. The upstream start.sh replaces it with $BASE_PATH at runtime. +# For HA ingress, the base path is the dynamic ingress entry (e.g. +# /api/hassio_ingress/). We perform the replacement here so the React +# Router basename and all asset/API URLs point through the ingress path. +# We intentionally do NOT export BASE_PATH so that the NestJS server keeps its +# routes at the root — nginx's rewrite rule strips the ingress prefix on the +# server side. +ingress_entry="$(bashio::addon.ingress_entry 2>/dev/null || true)" +if [ -n "$ingress_entry" ]; then + UI_DIST_DIR="/opt/app/apps/server/dist/ui" + if [ -d "$UI_DIST_DIR" ]; then + echo "[Maintainerr] Setting ingress base path: $ingress_entry" + find "$UI_DIST_DIR" -type f -not -path '*/node_modules/*' \ + -print0 | xargs -0 sed -i "s,/__PATH_PREFIX__,${ingress_entry},g" 2>/dev/null || true + fi +fi + # ─── Start Maintainerr as unprivileged node user ───────────────────────────── echo "[Maintainerr] Starting application on port ${UI_PORT:-6246}..." exec gosu node /opt/app/start.sh &