From 0388e229872b7d8bd81b8e4df9682460b5cd89ef Mon Sep 17 00:00:00 2001 From: pheralb Date: Sun, 10 Mar 2024 12:52:29 +0000 Subject: [PATCH] Add ``auth`` custom alias + update middleware auth imports --- src/middleware.ts | 7 ++----- tsconfig.json | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/middleware.ts b/src/middleware.ts index 53db190..06563b0 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -1,6 +1,6 @@ import { NextResponse, type NextRequest } from "next/server"; -import NextAuth from "next-auth"; -import authConfig from "auth.config"; +import { auth } from "auth"; + import { DEFAULT_LOGIN_REDIRECT_URL, apiAuthPrefix, @@ -9,11 +9,8 @@ import { publicRoutes, } from "./routes"; -const { auth } = NextAuth(authConfig); - const middleware = async (req: NextRequest, isLoggedIn: boolean) => { try { - const { nextUrl } = req; const isApiAuthRoute = nextUrl.pathname.startsWith(apiAuthPrefix); const isPublicRoute = publicRoutes.includes(nextUrl.pathname); diff --git a/tsconfig.json b/tsconfig.json index ccaa23d..598b5cc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,8 @@ "incremental": true, "baseUrl": ".", "paths": { - "@/*": ["./src/*"] + "@/*": ["./src/*"], + "auth": ["./auth.config.ts"] } }, "include": [