mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 06:11:15 +00:00
26 lines
742 B
TypeScript
26 lines
742 B
TypeScript
import type { NextAuthConfig } from "next-auth";
|
|
|
|
export default {
|
|
pages: {
|
|
signIn: "/login",
|
|
error: "/login",
|
|
},
|
|
callbacks: {
|
|
authorized({ auth, request: { nextUrl } }) {
|
|
const isLoggedIn = !!auth?.user;
|
|
const isAuthPage =
|
|
nextUrl.pathname.startsWith("/login") || nextUrl.pathname.startsWith("/register");
|
|
const isApiAuth = nextUrl.pathname.startsWith("/api/auth");
|
|
const isHealth = nextUrl.pathname.startsWith("/api/health");
|
|
|
|
if (isHealth || isApiAuth) return true;
|
|
if (isAuthPage) {
|
|
if (isLoggedIn) return Response.redirect(new URL("/dashboard", nextUrl));
|
|
return true;
|
|
}
|
|
return isLoggedIn;
|
|
},
|
|
},
|
|
providers: [],
|
|
} satisfies NextAuthConfig;
|