From a00b337703f3badc2a3678a737dd49a69870f92a Mon Sep 17 00:00:00 2001 From: Calum Muir Date: Sun, 7 Jun 2026 13:01:10 +0000 Subject: [PATCH] Store studio index.html outside dist/client/ to avoid static serving MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Astro didn't include the deleted public/studio/index.html in dist/client/ so the SSR route couldn't find it. Now we copy it from the studio build stage to dist/studio-index.html after the Astro build — accessible to the SSR route but invisible to the static file middleware. Co-Authored-By: Claude Sonnet 4.6 --- Dockerfile | 7 +++++-- src/pages/studio/[...path].ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4059b4b..bc4b7be 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,8 +26,8 @@ FROM base AS build COPY --from=deps /app/node_modules ./node_modules COPY . . COPY --from=studio-build /app/dist ./public/studio -# Remove index.html so /studio requests fall through to the SSR route, -# which rewrites /static/ asset paths to /studio/static/ before serving. +# Remove index.html from public so static middleware doesn't serve it — +# the SSR route rewrites asset paths before serving it. RUN rm -f ./public/studio/index.html ARG SANITY_PROJECT_ID ARG SANITY_DATASET=production @@ -36,6 +36,9 @@ ENV SANITY_PROJECT_ID=$SANITY_PROJECT_ID ENV SANITY_DATASET=$SANITY_DATASET ENV SANITY_API_TOKEN=$SANITY_API_TOKEN RUN npm run build +# Place studio index.html outside dist/client/ so SSR can read it without +# it being served as a static file. +COPY --from=studio-build /app/dist/index.html ./dist/studio-index.html # ── 5. Runtime ──────────────────────────────────────────────────────────────── FROM node:20-alpine AS runtime diff --git a/src/pages/studio/[...path].ts b/src/pages/studio/[...path].ts index da40acb..9fbc73e 100644 --- a/src/pages/studio/[...path].ts +++ b/src/pages/studio/[...path].ts @@ -5,7 +5,7 @@ import { join } from "path"; // Serve the studio SPA for all /studio/* paths (including /studio itself). // Static assets under /studio/assets/* are served before this route fires. export const GET: APIRoute = () => { - const indexPath = join(process.cwd(), "dist/client/studio/index.html"); + const indexPath = join(process.cwd(), "dist/studio-index.html"); if (!existsSync(indexPath)) { return new Response(