fix: support authenticated web deployments under a reverse proxy path

This commit is contained in:
AttilaNet
2026-11-10 20:01:44 +08:00
parent 0230a933b0
commit 99aff423d8
12 changed files with 529 additions and 31 deletions
+9 -3
View File
@@ -1,4 +1,5 @@
import {api, request} from './api.js';
import {apiPath, webPath} from './paths.js';
import {el, $, $$, clone, getPath, setPath, pathKey, textValue, number, chinaTime, download, csvBlob, optionsList, detailsList, tabKeys} from './dom.js';
import {PageView, PAGES} from './pages.js';
import {notice, dialog, confirm, filePicker, fileBase64} from './ui.js';
@@ -418,7 +419,7 @@ function renderLogs(reset=false) {
const line=el('div',{class:`log-entry ${entry.level || entry.kind || ''}`,'data-entry-id':entry.id});
const stamp=entry.time || entry.timestamp || entry.at || '';
line.append(el('span',{class:'log-time',text:chinaTime(stamp),title:String(stamp)}),document.createTextNode(entry.message || entry.operation || textValue(entry)));
if(entry.details_available || entry.detail_url){line.classList.add('inspectable');line.tabIndex=0;line.setAttribute('role','button');line.title='查看脱敏请求 / 响应 JSON';line.addEventListener('click',()=>showDebugEntry(account,entry));line.addEventListener('keydown',event=>{if(event.key==='Enter'||event.key===' '){event.preventDefault();showDebugEntry(account,entry);}});}
if(entry.details_available || entry.detail_url || entry.debug_url){line.classList.add('inspectable');line.tabIndex=0;line.setAttribute('role','button');line.title='查看脱敏请求 / 响应 JSON';line.addEventListener('click',()=>showDebugEntry(account,entry));line.addEventListener('keydown',event=>{if(event.key==='Enter'||event.key===' '){event.preventDefault();showDebugEntry(account,entry);}});}
root.append(line);
}
log.rendered=log.entries.length;
@@ -439,7 +440,12 @@ async function fetchLogs(account) {
async function showDebugEntry(account,entry) {
const pre=el('pre',{class:'debug-json',text:'正在读取所选条目的脱敏详情…'});const open=dialog('请求 / 响应详情(已脱敏)',pre,{info:true});
try{let detail;if(entry.detail_url&&new URL(entry.detail_url,location.href).origin===location.origin)detail=await request(entry.detail_url);else detail=await api.debugEntry(account.id,entry.id);pre.textContent=JSON.stringify(detail.details ?? detail,null,2);}catch(failure){pre.textContent=failure.message;}
try{
let path;
try{path=apiPath(entry.detail_url || entry.debug_url);}catch{/* Use the account's own endpoint for untrusted URLs. */}
const detail=await (path?request(path):api.debugEntry(account.id,entry.id));
pre.textContent=JSON.stringify(detail.details ?? detail,null,2);
}catch(failure){pre.textContent=failure.message;}
await open;
}
@@ -479,7 +485,7 @@ function hideWorkbench() {
function requireAuth() {
if(state.redirecting)return;
state.redirecting=true;hideWorkbench();location.replace('/login');
state.redirecting=true;hideWorkbench();location.replace(webPath('/login'));
}
async function bootstrap() {