web/middleware.tsblame
View source
da0f6511import { NextRequest, NextResponse } from "next/server";
da0f6512
da0f6513export function middleware(request: NextRequest) {
da0f6514 const host = request.headers.get("host") ?? "";
da0f6515 const hostname = host.split(":")[0]; // strip port
da0f6516
da0f6517 if (hostname.startsWith("canopy.")) {
da0f6518 const url = request.nextUrl.clone();
da0f6519 url.pathname = `/canopy${url.pathname}`;
da0f65110 return NextResponse.rewrite(url);
da0f65111 }
3cbdca612 if (hostname.startsWith("ring.")) {
3cbdca613 const url = request.nextUrl.clone();
3cbdca614 url.pathname = `/ring${url.pathname}`;
3cbdca615 return NextResponse.rewrite(url);
3cbdca616 }
0b4b58217 if (hostname.startsWith("collab.")) {
0b4b58218 const url = request.nextUrl.clone();
0b4b58219 url.pathname = `/collab${url.pathname}`;
0b4b58220 return NextResponse.rewrite(url);
0b4b58221 }
da0f65122 return NextResponse.next();
da0f65123}
da0f65124
da0f65125export const config = {
da0f65126 matcher: [
da0f65127 // Match all paths except Next.js internals and static files
0b4b58228 "/((?!_next/static|_next/image|favicon\\.svg|canopy-favicon\\.svg|ring-favicon\\.svg|collab-favicon\\.svg|api/).*)",
da0f65129 ],
da0f65130};