mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-18 13:34:08 +01:00
23 lines
731 B
TypeScript
23 lines
731 B
TypeScript
import { NextResponse } from "next/server";
|
|
import type { NextRequest } from "next/server";
|
|
|
|
export function middleware(request: NextRequest) {
|
|
const token = request.cookies.get("token");
|
|
if (!token) {
|
|
const url = request.nextUrl.clone();
|
|
url.pathname = "/auth/signin";
|
|
return NextResponse.redirect(url);
|
|
}
|
|
return NextResponse.next();
|
|
}
|
|
|
|
export const config = {
|
|
matcher: [
|
|
// This will match all paths that:
|
|
// - have at least one character after "/"
|
|
// - do NOT start with /_next/static, /_next/image, /favicon.ico, /hub, or /auth.
|
|
// (thus "/auth/signin", "/" and any "/hub" route are not processed by this middleware)
|
|
"/((?!_next/static|_next/image|favicon.ico|hub|auth).+)",
|
|
],
|
|
};
|