From ff70624283e9af9b679f2db09800caccb0ae9783 Mon Sep 17 00:00:00 2001 From: TheHamkerCat Date: Sat, 11 Jan 2025 04:31:04 +0530 Subject: [PATCH] fix: revert wut --- middleware.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/middleware.ts b/middleware.ts index d518af5..824cea0 100644 --- a/middleware.ts +++ b/middleware.ts @@ -3,20 +3,20 @@ import type { Session } from "better-auth/types"; import { type NextRequest, NextResponse } from "next/server"; export default async function authMiddleware(request: NextRequest) { - // const { data: session } = await betterFetch( - // "/api/auth/get-session", - // { - // baseURL: request.nextUrl.origin, - // headers: { - // //get the cookie from the request - // cookie: request.headers.get("cookie") || "", - // }, - // }, - // ); + const { data: session } = await betterFetch( + "/api/auth/get-session", + { + baseURL: request.nextUrl.origin, + headers: { + //get the cookie from the request + cookie: request.headers.get("cookie") || "", + }, + }, + ); - // if (!session) { - // return NextResponse.redirect(new URL("/login", request.url)); - // } + if (!session) { + return NextResponse.redirect(new URL("/login", request.url)); + } return NextResponse.next(); }