-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.ts
More file actions
25 lines (19 loc) · 876 Bytes
/
Copy pathproxy.ts
File metadata and controls
25 lines (19 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import createIntlMiddleware from "next-intl/middleware";
import { NextRequest, NextResponse } from "next/server";
import { routing } from "./i18n/routing";
const intl = createIntlMiddleware(routing);
// CLI clients hitting the apex get the plain-text resume instead of HTML.
const CLI_UA = /^(curl|wget|httpie|http)\//i;
export default function proxy(request: NextRequest) {
const { pathname } = request.nextUrl;
const ua = request.headers.get("user-agent") ?? "";
if (pathname === "/" && CLI_UA.test(ua)) {
return NextResponse.rewrite(new URL("/api/resume.txt", request.url));
}
return intl(request);
}
export const config = {
// Skip API/AX endpoints, internals, and any path with a file extension
// (favicons, images, robots.txt, sitemap.xml, llms.txt, *.md, …).
matcher: ["/((?!api|md/|_next|_vercel|\\.well-known|apple-icon|.*\\..*).*)"],
};