Update middleware.ts
This commit is contained in:
@@ -2,6 +2,13 @@ import { NextResponse } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
export async function middleware(req: NextRequest) {
|
||||
const pathname = new URL(req.url).pathname;
|
||||
|
||||
// Skip auth check for password reset page
|
||||
if (pathname.startsWith('/auth/reset-password')) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// Check for auth token in cookies
|
||||
const token = req.cookies.get("Authorization")?.value;
|
||||
|
||||
@@ -55,7 +62,6 @@ export async function middleware(req: NextRequest) {
|
||||
console.log("Middleware: Auth check successful");
|
||||
|
||||
// Admin-only protection for /admin routes
|
||||
const pathname = new URL(req.url).pathname;
|
||||
if (pathname.startsWith('/admin')) {
|
||||
try {
|
||||
const user = await res.json();
|
||||
@@ -78,5 +84,5 @@ export async function middleware(req: NextRequest) {
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ["/dashboard/:path*", "/admin/:path*"],
|
||||
matcher: ["/dashboard/:path*", "/admin/:path*", "/auth/reset-password/:path*"],
|
||||
};
|
||||
Reference in New Issue
Block a user