From fcc6a253b5d7c35fe0b1ef589fc9153ff17b21df Mon Sep 17 00:00:00 2001 From: Tom Tong Date: Thu, 18 Jun 2026 21:44:43 +0000 Subject: [PATCH] frontend: subpath-safe fetch() in /model command cmdModel() had the only two root-absolute fetch('/api/...') calls left in the frontend. Under a reverse proxy that mounts the app at a subpath (e.g. jupyter-server-proxy at /proxy//), a root-absolute path escapes the mount and 404s, so /model can't load the catalog or update the session. Resolve both against document.baseURI (falling back to location.href) like every other fetch in the frontend already does. Co-Authored-By: Claude Opus 4.8 --- static/commands.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/commands.js b/static/commands.js index 2cd0c6ad..ec7daaf7 100644 --- a/static/commands.js +++ b/static/commands.js @@ -547,7 +547,7 @@ async function cmdModel(args){ // CLI resolves against the full catalog, so /model must too. (#3368) let modelsData=null; try { - const resp=await fetch('/api/models'); + const resp=await fetch(new URL('api/models',document.baseURI||location.href).href); if(resp.ok){ modelsData=await resp.json(); const aliases=modelsData.aliases||{}; @@ -587,7 +587,7 @@ async function cmdModel(args){ if(!match && !versionedNoSnap && S&&S.session&&S.session.session_id){ const provider=q.slice(0,q.indexOf('/')); try{ - const resp=await fetch('/api/session/update',{ + const resp=await fetch(new URL('api/session/update',document.baseURI||location.href).href,{ method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({