Files
hassio-addons/seerr/rootfs/etc/cont-init.d/32-nginx_ingress.sh
Alexandre 29ce08c162 fix(seerr): reapply the asset cache-bust reverted by the builder (#2975) (#2997)
Restores #2993 verbatim. It was merged, then reverted by the builder's
revert-on-failure job a minute later - not because of anything in it, but
because EndBug/add-and-commit's floating v11 tag had moved to a release whose
action.yml no longer loads, so prebuild-sanitize failed before running a step.
The tag is pinned back to v11.0.0 in #2996, which has to land first for the
builder to get past that job.

The change itself is unchanged and still verified against the real njs module:
the rewritten /_next paths carry the add-on version, njs strips the marker
before proxying, so a browser holding the year-cached rewritten bundle fetches
fresh URLs on the first load after the update.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 07:30:20 +02:00

39 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
set -e
####################
# Seerr Ingress #
####################
bashio::log.info "Configuring Nginx for ingress..."
ingress_port=$(bashio::addon.ingress_port)
ingress_interface=$(bashio::addon.ip_address)
ingress_entry=$(bashio::addon.ingress_entry)
# Cache-busting marker for the rewritten JavaScript bundle.
#
# Seerr serves /_next/static/ as "public, max-age=31536000, immutable", and
# nginx's sub_filter strips ETag and Last-Modified off every response it
# rewrites, while the HTML naming those chunks is served "no-store" and keeps
# naming the same URLs. A browser therefore pins the bundle this add-on rewrote
# on its first visit for a year, with no request left that could deliver a
# later change to the sub_filter rules below - which is how #2975 outlived two
# fixes. Folding the version into the asset path gives every release its own
# URLs. njs/ingress.js strips the marker again before proxying.
#
# BUILD_VERSION is the add-on version baked in at build time (it is also what
# bashio::addon.version returns). Only [A-Za-z0-9-] survives: the marker ends up
# inside a regex literal in Seerr's own bundle, where a dot would be a wildcard.
asset_tag="ha-$(printf '%s' "${BUILD_VERSION:-0}" | tr -c 'A-Za-z0-9' '-')"
# Update ingress.conf with actual values
sed -i "s|%%port%%|${ingress_port}|g" /etc/nginx/servers/ingress.conf
sed -i "s|%%interface%%|${ingress_interface}|g" /etc/nginx/servers/ingress.conf
sed -i "s|%%ingress_entry%%|${ingress_entry}|g" /etc/nginx/servers/ingress.conf
sed -i "s|%%ingress_entry_escaped%%|${ingress_entry//\//\\\\\/}|g" /etc/nginx/servers/ingress.conf
sed -i "s|%%asset_tag%%|${asset_tag}|g" /etc/nginx/servers/ingress.conf
bashio::log.info "Nginx ingress configured on ${ingress_interface}:${ingress_port} (asset tag ${asset_tag})"