未认证访问登录后误进首页:302 /login 带 next=originalUrl,登录成功/token静默恢复/bfcache僵尸页踢回均按 next 回跳原页(仅认同源/路径,拦//与反斜杠防开放重定向);前端 core/files 的 401 跳登录同样带上当前页

This commit is contained in:
2026-09-26 10:13:45 +08:00
parent 6ff1646c14
commit 9892e48cbe
4 changed files with 25 additions and 8 deletions
+2 -1
View File
@@ -129,7 +129,8 @@
}
throw e;
}
if (res.status === 401) { location.href = '/login'; throw new Error('未登录'); }
// 运行中登录态失效:带上当前页 URL,重新登录后原页返回
if (res.status === 401) { location.href = '/login?next=' + encodeURIComponent(location.pathname + location.search); throw new Error('未登录'); }
if (!res.ok) {
let msg = 'HTTP ' + res.status;
try { msg = (await res.json()).error || msg; } catch (_) {}