18 lines
433 B
TypeScript
18 lines
433 B
TypeScript
import { auth } from "@/lib/auth";
|
|
import { NextResponse } from "next/server";
|
|
|
|
export default auth((req) => {
|
|
const isLoggedIn = !!req.auth;
|
|
const isOnDashboard = req.nextUrl.pathname.startsWith("/dashboard");
|
|
|
|
if (isOnDashboard && !isLoggedIn) {
|
|
return NextResponse.redirect(new URL("/login", req.url));
|
|
}
|
|
|
|
return NextResponse.next();
|
|
});
|
|
|
|
export const config = {
|
|
matcher: ["/dashboard/:path*"],
|
|
};
|