MCPcopy Index your code
hub / github.com/anomalyco/opencode / handler

Function handler

packages/console/app/src/routes/docs/[...path].ts:5–23  ·  view source on GitHub ↗
(evt: APIEvent)

Source from the content-addressed store, hash-verified

3import { cookie, docs, localeFromRequest, tag } from "~/lib/language"
4
5async function handler(evt: APIEvent) {
6 const req = evt.request.clone()
7 const url = new URL(req.url)
8 const locale = localeFromRequest(req)
9 const host = Resource.App.stage === "production" ? "docs.opencode.ai" : "docs.dev.opencode.ai"
10 const targetUrl = `https://${host}${docs(locale, url.pathname)}${url.search}`
11
12 const headers = new Headers(req.headers)
13 headers.set("accept-language", tag(locale))
14
15 const response = await fetch(targetUrl, {
16 method: req.method,
17 headers,
18 body: req.body,
19 })
20 const next = new Response(response.body, response)
21 next.headers.append("set-cookie", cookie(locale))
22 return next
23}
24
25export const GET = handler
26export const POST = handler

Callers

nothing calls this directly

Calls 8

localeFromRequestFunction · 0.90
docsFunction · 0.90
tagFunction · 0.90
cookieFunction · 0.90
cloneMethod · 0.80
fetchFunction · 0.50
setMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected