Skip to content

Commit

Permalink
Add auth custom alias + update middleware auth imports
Browse files Browse the repository at this point in the history
  • Loading branch information
pheralb committed Mar 10, 2024
1 parent 740be5e commit 0388e22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"incremental": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
"@/*": ["./src/*"],
"auth": ["./auth.config.ts"]
}
},
"include": [
Expand Down

0 comments on commit 0388e22

Please sign in to comment.