From b31106c44a4f18022e4cf62748936fd2c246e272 Mon Sep 17 00:00:00 2001 From: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Date: Sat, 30 May 2026 15:20:34 +0800 Subject: [PATCH] fix(docs): deploy on blog changes, correct GitHub repo, stop cross-locale homepage caching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three fixes prompted by live-site issues: 1. deploy-docs.yml only triggered on content/docs/** — blog-only changes (like the expanded 'extend existing systems' post in #12) never deployed. Add content/blog/** to the path filter. 2. gitConfig.repo was 'spec' → the navbar GitHub link and the docs 'edit this page' link pointed at objectstack-ai/spec. Correct to objectstack-ai/objectos (where this content actually lives). 3. The prefix-less homepage ('/') is statically cached with s-maxage=31536000 and no Vary on Accept-Language. Its body, however, is language-negotiated by middleware — so a shared cache stored the English homepage at '/' and served it to every visitor, and non-English browsers stopped being redirected to their localized path. Mark the default-locale rewrite response 'private, no-cache' so the edge never shares it and middleware re-runs language detection per request. (Verified the redirect logic itself is correct: a cache-miss request with Accept-Language: zh-CN already 307s to /zh-Hans.) --- .github/workflows/deploy-docs.yml | 1 + apps/docs/lib/layout.shared.tsx | 2 +- apps/docs/middleware.ts | 11 ++++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index ff5c83d..d7350c5 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -6,6 +6,7 @@ on: paths: - 'apps/docs/**' - 'content/docs/**' + - 'content/blog/**' - 'pnpm-lock.yaml' - '.github/workflows/deploy-docs.yml' workflow_dispatch: diff --git a/apps/docs/lib/layout.shared.tsx b/apps/docs/lib/layout.shared.tsx index b1e6341..dc4eec6 100644 --- a/apps/docs/lib/layout.shared.tsx +++ b/apps/docs/lib/layout.shared.tsx @@ -3,7 +3,7 @@ import Image from 'next/image'; export const gitConfig = { user: 'objectstack-ai', - repo: 'spec', + repo: 'objectos', branch: 'main', }; diff --git a/apps/docs/middleware.ts b/apps/docs/middleware.ts index 3d15e7d..532449d 100644 --- a/apps/docs/middleware.ts +++ b/apps/docs/middleware.ts @@ -157,7 +157,16 @@ export default function middleware(request: NextRequest) { const url = new URL(request.url); // Handle root path specially to avoid double slashes url.pathname = pathname === '/' ? `/${i18n.defaultLanguage}` : `/${i18n.defaultLanguage}${pathname}`; - return NextResponse.rewrite(url); + const response = NextResponse.rewrite(url); + // This is a locale-negotiated response for a prefix-less path (e.g. "/"). + // The underlying page is statically cached with a long s-maxage, but the + // *result here depends on the visitor's language* — so it must never be + // stored in a shared cache, or the CDN would serve this (default-locale) + // HTML to every visitor and non-English browsers would stop being + // redirected to their localized path. Mark it private so the edge skips it + // and middleware re-runs language detection on every request. + response.headers.set('Cache-Control', 'private, no-cache, must-revalidate'); + return response; } // For non-default languages, redirect to the localized path