diff --git a/apps/docs/README.md b/apps/docs/README.md index 4a53561a..75d580d2 100644 --- a/apps/docs/README.md +++ b/apps/docs/README.md @@ -42,6 +42,8 @@ The Worker uses its `AI` binding for answer generation and `CHAT_RATE_LIMITER` f First deploy and inspect the direct Workers URL while Mintlify remains live. Keep `https://supermemory.ai/docs/` as the canonical URL. Switch the existing `/docs/*` proxy or Cloudflare route to this Worker only after verification; forward the full path without stripping `/docs`. Preserve the rest of the main website. The Wrangler configuration does not change public DNS or routes automatically. +Same-site redirects use relative paths so previews and reverse-proxy deployments keep the browser on the public origin. + Mintlify's repository integration does not run Holocron's preparation step, so it cannot fetch the generated OpenAPI file or validate generated API-page links. Its deployment and link checks fail against this migration. Before merging, retire the legacy repository deployment integration and replace any required Mintlify checks with the `Docs - Build, Deploy and Index` build job. Keep the existing Mintlify-hosted site live until the routing cutover is verified. ## Documentation indexing diff --git a/apps/docs/src/server.ts b/apps/docs/src/server.ts index d1b928bd..9efcff6f 100644 --- a/apps/docs/src/server.ts +++ b/apps/docs/src/server.ts @@ -13,6 +13,17 @@ export default { if (new URL(request.url).pathname === "/docs/mcp") { return docsMcp(request, env) } - return app.handle(request) + const response = await app.handle(request) + const location = response.headers.get("Location") + if (!location) return response + const target = new URL(location, request.url) + if (target.origin !== new URL(request.url).origin) return response + const headers = new Headers(response.headers) + headers.set("Location", `${target.pathname}${target.search}${target.hash}`) + return new Response(response.body, { + status: response.status, + statusText: response.statusText, + headers, + }) }, }