mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-07-14 18:15:56 -04:00
32 lines
692 B
TypeScript
32 lines
692 B
TypeScript
import { getSessionCookie } from "better-auth/cookies";
|
|
import { type NextRequest, NextResponse } from "next/server";
|
|
|
|
export function proxy(request: NextRequest) {
|
|
const sessionCookie = getSessionCookie(request);
|
|
const { pathname } = request.nextUrl;
|
|
|
|
if (pathname === "/") {
|
|
if (sessionCookie) {
|
|
return NextResponse.redirect(new URL("/dashboard", request.url));
|
|
}
|
|
return NextResponse.next();
|
|
}
|
|
|
|
if (!sessionCookie) {
|
|
return NextResponse.redirect(new URL("/login", request.url));
|
|
}
|
|
|
|
return NextResponse.next();
|
|
}
|
|
|
|
export const config = {
|
|
matcher: [
|
|
"/",
|
|
"/dashboard",
|
|
"/explore",
|
|
"/settings",
|
|
"/setup",
|
|
"/titles/:path*",
|
|
],
|
|
};
|