From 8e2cd0b0d6a5672858959471eadbbfa31b17176b Mon Sep 17 00:00:00 2001 From: Calum Muir Date: Sun, 7 Jun 2026 12:55:01 +0000 Subject: [PATCH] Rewrite studio asset paths from /static/ to /studio/static/ at serve time Sanity v3 basePath only affects the SPA router, not Vite's build output. The built index.html hardcodes /static/ so we rewrite on the way out. Co-Authored-By: Claude Sonnet 4.6 --- src/pages/studio/[...path].ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/studio/[...path].ts b/src/pages/studio/[...path].ts index 748be75..da40acb 100644 --- a/src/pages/studio/[...path].ts +++ b/src/pages/studio/[...path].ts @@ -14,7 +14,13 @@ export const GET: APIRoute = () => { ); } - return new Response(readFileSync(indexPath, "utf-8"), { + // Rewrite absolute asset paths from /static/ to /studio/static/ so + // the studio's JS/CSS/icons load correctly when hosted at /studio. + const html = readFileSync(indexPath, "utf-8") + .replaceAll('="/static/', '="/studio/static/') + .replaceAll("='/static/", "='/studio/static/"); + + return new Response(html, { status: 200, headers: { "Content-Type": "text/html; charset=utf-8" }, });