fix(docs): preserve public origins in preview redirects

This commit is contained in:
Dhravya 2026-10-02 00:52:01 +00:00
parent baf77685c9
commit 7e17c5b514
No known key found for this signature in database
GPG key ID: AB7AE7EA7D4AF7AD
2 changed files with 14 additions and 1 deletions

View file

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

View file

@ -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,
})
},
}