mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 10:18:46 +03:00
fix(console): redirect old zen and go docs from docs proxy
This commit is contained in:
@@ -5,6 +5,11 @@ import { cookie, docs, localeFromRequest, tag } from "~/lib/language"
|
||||
async function handler(evt: APIEvent) {
|
||||
const req = evt.request.clone()
|
||||
const url = new URL(req.url)
|
||||
const moved = /^\/docs\/(?:[^/]+\/)?(zen|go)\/?$/.exec(url.pathname)
|
||||
if (moved) {
|
||||
return Response.redirect(new URL(moved[1] === "go" ? "/v2/docs/console/go/" : "/v2/docs/console/models/", url), 302)
|
||||
}
|
||||
|
||||
const locale = localeFromRequest(req)
|
||||
const host = Resource.App.stage === "production" ? "docs.opencode.ai" : "docs.dev.opencode.ai"
|
||||
const targetUrl = `https://${host}${docs(locale, url.pathname)}${url.search}`
|
||||
|
||||
@@ -78,11 +78,6 @@ function localeFromAcceptLanguage(header: string | null) {
|
||||
}
|
||||
|
||||
export const onRequest = defineMiddleware((ctx, next) => {
|
||||
const moved = /^\/docs\/(?:[^/]+\/)?(zen|go)\/?$/.exec(ctx.url.pathname)
|
||||
if (moved) {
|
||||
return redirect(ctx.url, moved[1] === "go" ? "/v2/docs/console/go/" : "/v2/docs/console/models/")
|
||||
}
|
||||
|
||||
const alias = docsAlias(ctx.url.pathname)
|
||||
if (alias) {
|
||||
return redirect(ctx.url, alias.path, alias.locale)
|
||||
|
||||
Reference in New Issue
Block a user