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 <noreply@anthropic.com>
This commit is contained in:
parent
847952228f
commit
8e2cd0b0d6
1 changed files with 7 additions and 1 deletions
|
|
@ -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" },
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue