tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
add middleware with hardcoded rewrite
awarm.space
1 year ago
d3955f56
0bc3d445
+22
1 changed file
expand all
collapse all
unified
split
middleware.ts
+22
middleware.ts
···
1
1
+
import { NextRequest, NextResponse } from "next/server";
2
2
+
3
3
+
export const config = {
4
4
+
matcher: [
5
5
+
/*
6
6
+
* Match all paths except for:
7
7
+
* 1. /api routes
8
8
+
* 2. /_next (Next.js internals)
9
9
+
* 3. /_static (inside /public)
10
10
+
* 4. all root files inside /public (e.g. /favicon.ico)
11
11
+
*/
12
12
+
"/((?!api/|_next/|_static/|_vercel|[\\w-]+\\.\\w+).*)",
13
13
+
],
14
14
+
};
15
15
+
16
16
+
export default async function middleware(req: NextRequest) {
17
17
+
let hostname = req.headers.get("host")!;
18
18
+
if (hostname === "guilds.nyc")
19
19
+
return NextResponse.rewrite(
20
20
+
new URL("/b64bc712-c9c1-4ed3-a8f4-d33f33d3bfdb", req.url),
21
21
+
);
22
22
+
}