fix: rewrite proxy links with token prefix and correct login redirect
Build and Push to GHCR / build-and-push (push) Has been cancelled

- Add ModifyResponse to DynamicProxy to inject token-prefix JS and
  rewrite Location headers, same as GitHub proxy already did.
- Improve injectTokenPrefixScript to rewrite href/src/action on page
  load and watch for dynamically added elements via MutationObserver.
- Replace hardcoded ../ login redirect with pathname-based calculation
  so it works regardless of admin_path config.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <[email protected]>
This commit is contained in:
Agent
2026-05-24 17:27:38 +08:00
co-authored by HAPI
parent d6623fc150
commit f03eacaf20
3 changed files with 58 additions and 5 deletions
+4 -2
View File
@@ -109,7 +109,8 @@
try {
const res = await fetch('/api/auth/me', { credentials: 'same-origin' });
if (res.ok) {
window.location.href = '../';
const adminRoot = window.location.pathname.replace(/\/login\/?$/, '/');
window.location.href = adminRoot;
}
} catch (e) {}
}
@@ -138,7 +139,8 @@
});
if (res.ok) {
window.location.href = '../';
const adminRoot = window.location.pathname.replace(/\/login\/?$/, '/');
window.location.href = adminRoot;
} else {
const data = await res.json().catch(() => ({}));
errorEl.textContent = data.error || '用户名或密码错误';