17 lines
372 B
TypeScript
17 lines
372 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { getAuth } from "./lib/auth";
|
|
|
|
export async function middleware(request: NextRequest) {
|
|
const auth = await getAuth();
|
|
|
|
if (auth) {
|
|
return NextResponse.next();
|
|
} else {
|
|
return NextResponse.redirect(new URL("/auth", request.url));
|
|
}
|
|
}
|
|
|
|
export const config = {
|
|
matcher: "/notes/:path*",
|
|
};
|