30 lines
868 B
JavaScript
30 lines
868 B
JavaScript
// middleware.js
|
|
// import { createMiddlewareClient } from "@supabase/auth-helpers-nextjs";
|
|
import { NextResponse } from "next/server";
|
|
|
|
export async function middleware(req) {
|
|
const res = NextResponse.next();
|
|
// const supabase = createMiddlewareClient({ req, res });
|
|
// const {
|
|
// data: { session },
|
|
// } = await supabase.auth.getSession();
|
|
|
|
// if (!session && req.nextUrl.pathname.startsWith("/client-area")) {
|
|
// return NextResponse.redirect(new URL("/login", req.url));
|
|
// }
|
|
|
|
// Protect reset-password route
|
|
if (req.nextUrl.pathname === "/reset-password") {
|
|
const accessToken = req.nextUrl.searchParams.get("access_token");
|
|
if (!accessToken) {
|
|
return NextResponse.redirect(new URL("/login", req.url));
|
|
}
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
export const config = {
|
|
matcher: ["/client-area/:path*", "/reset-password"],
|
|
};
|