forked from sqwu/helper
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmiddleware.ts
More file actions
21 lines (19 loc) · 795 Bytes
/
Copy pathmiddleware.ts
File metadata and controls
21 lines (19 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { NextResponse, NextRequest } from "next/server";
import { updateSession } from "@/lib/supabase/middleware";
export const middleware = (request: NextRequest) => {
// Skip auth redirects when accessed via Laborario's rewrite proxy
// (already protected by Laborario's Basic Auth)
const forwardedHost = request.headers.get("x-forwarded-host");
if (forwardedHost && !forwardedHost.includes("helper")) {
return NextResponse.next();
}
return updateSession(request);
};
export const config = {
matcher: [
// Skip Next.js internals and all static files, unless found in search params
"/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)",
// Always run for API routes
"/(api|trpc)(.*)",
],
};