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

Function onRequest

packages/console/app/src/middleware.ts:6–19  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

4
5export default createMiddleware({
6 onRequest(event) {
7 const url = new URL(event.request.url)
8 const locale = fromPathname(url.pathname)
9 if (locale) {
10 url.pathname = strip(url.pathname)
11 const request = new Request(url, event.request)
12 request.headers.set(LOCALE_HEADER, locale)
13 event.request = request
14 event.response.headers.append("set-cookie", cookie(locale))
15 }
16
17 const referralCode = normalizeReferralCode(url.searchParams.get("ref"))
18 if (referralCode) event.response.headers.append("set-cookie", referralCookie(referralCode))
19 },
20})

Callers 2

httpClientFunction · 0.85
createSseClientFunction · 0.85

Calls 8

fromPathnameFunction · 0.90
stripFunction · 0.90
cookieFunction · 0.90
normalizeReferralCodeFunction · 0.90
referralCookieFunction · 0.90
getMethod · 0.65
setMethod · 0.45
appendMethod · 0.45

Tested by 1

httpClientFunction · 0.68