NextAuth

ํ•™์Šตํ‚ค์›Œ๋“œ

  • ์„ค์น˜ ๋ฐ ์„ธํŒ…

Next Auth

์„ค์น˜ ๋ฐ ์„ธํŒ…

Next14 ๋ฒ„์ „์€ ํ˜„์žฌ ํ˜ธํ™˜์„ฑ ๋ฌธ์ œ ์žˆ์Œ (24.06.13 ๊ธฐ์ค€)

npm install next-auth@beta

ํ„ฐ๋ฏธ๋„์— ์ž…๋ ฅํ•ด์„œ ๋‚˜์˜จ ๋ฌธ์ž๋ฅผ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋กœ ์ง€์ •

openssl rand -base64 33
AUTH_SECRET= ํ™˜๊ฒฝ๋ณ€์ˆ˜์ง€์ •

src/auth.ts

import NextAuth from 'next-auth';

export const { handlers, signIn, signOut, auth } = NextAuth({
  providers: [],
});

app/api/auth/[...nextauth]/route.ts

src/middleware.ts

  • ๐Ÿšจ ๋ฐฐํฌ๋ฅผ ์œ„ํ•ด bulid ํ•˜๋ฉด ํ•ด๋‹น ํŒŒ์ผ error

  • ํ•ด๋‹น ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉ๋กœ ๋ณ€๊ฒฝ ํ•ด์•ผํ•จ

Last updated