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:
parent
7911a32676
commit
a00b337703
2 changed files with 6 additions and 3 deletions
|
|
@ -26,8 +26,8 @@ FROM base AS build
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
COPY --from=studio-build /app/dist ./public/studio
|
COPY --from=studio-build /app/dist ./public/studio
|
||||||
# Remove index.html so /studio requests fall through to the SSR route,
|
# Remove index.html from public so static middleware doesn't serve it —
|
||||||
# which rewrites /static/ asset paths to /studio/static/ before serving.
|
# the SSR route rewrites asset paths before serving it.
|
||||||
RUN rm -f ./public/studio/index.html
|
RUN rm -f ./public/studio/index.html
|
||||||
ARG SANITY_PROJECT_ID
|
ARG SANITY_PROJECT_ID
|
||||||
ARG SANITY_DATASET=production
|
ARG SANITY_DATASET=production
|
||||||
|
|
@ -36,6 +36,9 @@ ENV SANITY_PROJECT_ID=$SANITY_PROJECT_ID
|
||||||
ENV SANITY_DATASET=$SANITY_DATASET
|
ENV SANITY_DATASET=$SANITY_DATASET
|
||||||
ENV SANITY_API_TOKEN=$SANITY_API_TOKEN
|
ENV SANITY_API_TOKEN=$SANITY_API_TOKEN
|
||||||
RUN npm run build
|
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 ────────────────────────────────────────────────────────────────
|
# ── 5. Runtime ────────────────────────────────────────────────────────────────
|
||||||
FROM node:20-alpine AS runtime
|
FROM node:20-alpine AS runtime
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { join } from "path";
|
||||||
// Serve the studio SPA for all /studio/* paths (including /studio itself).
|
// Serve the studio SPA for all /studio/* paths (including /studio itself).
|
||||||
// Static assets under /studio/assets/* are served before this route fires.
|
// Static assets under /studio/assets/* are served before this route fires.
|
||||||
export const GET: APIRoute = () => {
|
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)) {
|
if (!existsSync(indexPath)) {
|
||||||
return new Response(
|
return new Response(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue