Fix: Middlerawe/1

This commit is contained in:
2024-11-21 14:35:28 +08:00
parent 7e9dfce293
commit cc690eec06
12 changed files with 32 additions and 18 deletions

View File

@@ -1,12 +1,27 @@
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import _ from "lodash";
import { NextRequest, NextResponse } from "next/server";
// This function can be marked `async` if using `await` inside
export function middleware(request: NextRequest) {
return NextResponse.redirect(new URL("/home", request.url));
let cookies = request.cookies.get("mySession");
console.log(cookies);
if (
!cookies ||
!cookies?.value ||
_.isEmpty(cookies?.value) ||
_.isUndefined(cookies?.value)
) {
return NextResponse.redirect(new URL("/", request.url));
}
// return NextResponse.redirect(new URL("/", request.url));
}
// See "Matching Paths" below to learn more
export const config = {
matcher: "/about/:path*",
matcher: [
"/((?!_next|static|favicon.ico|manifest).*)",
],
};