- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.ts
More file actions
Latest commit
22 lines (15 loc) · 630 Bytes
/
Copy pathproxy.ts
File metadata and controls
22 lines (15 loc) · 630 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
importtype{NextRequest}from"next/server";
import{NextResponse}from"next/server";
constMARKDOWN_SUFFIX=".md";
exportfunctionproxy(request: NextRequest){
const{ pathname }=request.nextUrl;
if(!pathname.endsWith(MARKDOWN_SUFFIX))returnNextResponse.next();
letsourcePath=pathname.slice(0,-MARKDOWN_SUFFIX.length)||"/";
if(sourcePath==="/index")sourcePath="/";
constdestination=request.nextUrl.clone();
destination.pathname=`/llm-markdown${sourcePath}`;
returnNextResponse.rewrite(destination);
}
exportconstconfig={
matcher: ["/((?!api/|admin/|_next/).*\\.md)"],
};