MCPcopy Create free account
hub / github.com/pqoqubbw/icons / proxy

Function proxy

proxy.ts:35–55  ·  view source on GitHub ↗
(req: NextRequest)

Source from the content-addressed store, hash-verified

33};
34
35export function proxy(req: NextRequest) {
36 const { pathname, search } = req.nextUrl;
37
38 if (pathname.endsWith(".md") && !PASSTHROUGH_PATHS.has(pathname)) {
39 const realPath = pathname.replace(MD_SUFFIX, "") || "/";
40 const target = toMdRewrite(realPath);
41 return NextResponse.rewrite(new URL(`${target}${search}`, req.url));
42 }
43
44 const accept = req.headers.get("accept") ?? "";
45 if (!accept.includes("text/markdown")) {
46 return NextResponse.next();
47 }
48
49 if (isPassthrough(pathname) || FILE_EXTENSION.test(pathname)) {
50 return NextResponse.next();
51 }
52
53 const target = toMdRewrite(pathname);
54 return NextResponse.rewrite(new URL(`${target}${search}`, req.url));
55}
56
57export const proxyConfig = {
58 matcher: ["/((?!_next/).*)"],

Callers

nothing calls this directly

Calls 2

toMdRewriteFunction · 0.85
isPassthroughFunction · 0.85

Tested by

no test coverage detected