From 49471e9f34707cc801029bbb78434e9fe35130b6 Mon Sep 17 00:00:00 2001 From: Claude Agent Date: Mon, 16 Mar 2026 15:19:50 +0000 Subject: [PATCH] fix(js): patch fetch to prepend ROOT_PATH for IIS reverse proxy All relative /api/... calls automatically get /gomag prefix via global fetch wrapper in shared.js. ROOT_PATH injected from template. Co-Authored-By: Claude Sonnet 4.6 --- api/app/static/js/shared.js | 11 +++++++++++ api/app/templates/base.html | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/api/app/static/js/shared.js b/api/app/static/js/shared.js index b5206db..2078d7b 100644 --- a/api/app/static/js/shared.js +++ b/api/app/static/js/shared.js @@ -1,5 +1,16 @@ // shared.js - Unified utilities for all pages +// ── Root path patch — prepend ROOT_PATH to all relative fetch calls ─────── +(function() { + const _fetch = window.fetch.bind(window); + window.fetch = function(url, ...args) { + if (typeof url === 'string' && url.startsWith('/') && window.ROOT_PATH) { + url = window.ROOT_PATH + url; + } + return _fetch(url, ...args); + }; +})(); + // ── HTML escaping ───────────────────────────────── function esc(s) { if (s == null) return ''; diff --git a/api/app/templates/base.html b/api/app/templates/base.html index 9f4a29e..cbc2e65 100644 --- a/api/app/templates/base.html +++ b/api/app/templates/base.html @@ -27,8 +27,9 @@ {% block content %}{% endblock %} + - + {% block scripts %}{% endblock %}