mirror of
https://github.com/jnsahaj/tweakcn.git
synced 2026-09-24 23:31:41 +08:00
28 lines
659 B
TypeScript
28 lines
659 B
TypeScript
import { NextResponse, type NextRequest } from "next/server";
|
|
import { headers } from "next/headers";
|
|
import { auth } from "@/lib/auth";
|
|
|
|
import { apiAuthPrefix } from "./routes";
|
|
|
|
export async function middleware(request: NextRequest) {
|
|
const session = await auth.api.getSession({
|
|
headers: await headers(),
|
|
});
|
|
|
|
const isApiAuth = request.nextUrl.pathname.startsWith(apiAuthPrefix);
|
|
|
|
if (isApiAuth) {
|
|
return NextResponse.next();
|
|
}
|
|
|
|
if (!session) {
|
|
return NextResponse.redirect(new URL("/editor/theme", request.url));
|
|
}
|
|
|
|
return NextResponse.next();
|
|
}
|
|
|
|
export const config = {
|
|
matcher: ["/editor/theme/:themeId", "/dashboard"],
|
|
};
|