Store studio index.html outside dist/client/ to avoid static serving

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 <noreply@anthropic.com>
This commit is contained in:
Calum Muir 2026-06-07 13:01:10 +00:00
parent 7911a32676
commit a00b337703
2 changed files with 6 additions and 3 deletions

View file

@ -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

View file

@ -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(