From a16f5a6e1d86fc6cf48f29dd8fb1f3de8370fc77 Mon Sep 17 00:00:00 2001 From: ngc2207 Date: Sun, 29 Dec 2024 11:04:17 +0800 Subject: [PATCH] feat(auth): add basic Auth.js configuration --- package.json | 1 + src/app/api/auth/[...nextauth]/route.ts | 2 ++ src/auth.ts | 5 +++++ src/middleware.ts | 1 + 4 files changed, 9 insertions(+) create mode 100644 src/app/api/auth/[...nextauth]/route.ts create mode 100644 src/auth.ts create mode 100644 src/middleware.ts diff --git a/package.json b/package.json index 17532ab..faeb1ea 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "clsx": "^2.1.1", "lucide-react": "^0.469.0", "next": "15.0.3", + "next-auth": "^5.0.0-beta.25", "react": "19.0.0-rc-66855b96-20241106", "react-dom": "19.0.0-rc-66855b96-20241106", "tailwind-merge": "^2.6.0", diff --git a/src/app/api/auth/[...nextauth]/route.ts b/src/app/api/auth/[...nextauth]/route.ts new file mode 100644 index 0000000..7c62e2d --- /dev/null +++ b/src/app/api/auth/[...nextauth]/route.ts @@ -0,0 +1,2 @@ +import { handlers } from "@/auth"; +export const { GET, POST } = handlers; diff --git a/src/auth.ts b/src/auth.ts new file mode 100644 index 0000000..3be7be6 --- /dev/null +++ b/src/auth.ts @@ -0,0 +1,5 @@ +import NextAuth from "next-auth"; + +export const { handlers, signIn, signOut, auth } = NextAuth({ + providers: [], +}); diff --git a/src/middleware.ts b/src/middleware.ts new file mode 100644 index 0000000..8155fe0 --- /dev/null +++ b/src/middleware.ts @@ -0,0 +1 @@ +export { auth as middleware } from "@/auth";