diff --git a/Makefile b/Makefile index 2ce2b3c..5239d2f 100644 --- a/Makefile +++ b/Makefile @@ -412,8 +412,12 @@ prepare-stockholm: rm -f "$(STOCKHOLM_DIR)/js/browse.js.bak" @# Patch bridge JS: replace hardcoded /api/* paths with __stockholmBase-prefixed @# versions so the bridge works when Stockholm is mounted under a base path. + @# browser_http_proxy.js declares the proxy URL as a top-level constant; + @# without patching it, requests from a /stockholm/* page hit /api/http-proxy + @# directly and 404 because the proxy is mounted under the base path. @# Also fix resolveWebviewUrl to include the base path when resolving relative URLs. @python3 scripts/patch-stockholm-bridge.py \ + "$(STOCKHOLM_DIR)/js/browser_http_proxy.js" \ "$(STOCKHOLM_DIR)/js/browser_native_bridge.js" \ "$(STOCKHOLM_DIR)/js/app_comm.js" \ "$(STOCKHOLM_DIR)/setup/js/app_comm.js" diff --git a/scripts/patch-stockholm-bridge.py b/scripts/patch-stockholm-bridge.py index ad529dc..acf1dc1 100644 --- a/scripts/patch-stockholm-bridge.py +++ b/scripts/patch-stockholm-bridge.py @@ -21,6 +21,26 @@ REPLACEMENTS = [ 'var proxyPath = "/api/http-proxy";', 'var proxyPath = (window.__stockholmBase||"") + "/api/http-proxy";', ), + ( + # The standalone /api/http-proxy declaration in browser_http_proxy.js + # uses an UPPERCASE constant name. Same shape as above, different + # identifier — keep both replacements; the lowercase one applies to + # app_comm.js, the uppercase one to browser_http_proxy.js. + 'var PROXY_PATH = "/api/http-proxy";', + 'var PROXY_PATH = (window.__stockholmBase||"") + "/api/http-proxy";', + ), + ( + # browser_http_proxy.js's IIFE evaluates PROXY_PATH at script-load + # time, but the injected bootstrap that defines window.__stockholmBase + # is placed just before — i.e. after the