Adding a basic version of next-auth-js using Discord and ensuring an authenticated user can fetch prompts from the real backend using an API middlelayer

This commit is contained in:
Keith Stevens
2022-12-14 11:49:42 +09:00
parent 38349b6661
commit 1f5e563b1d
7 changed files with 463 additions and 26 deletions
+19
View File
@@ -0,0 +1,19 @@
import NextAuth from "next-auth";
import DiscordProvider from "next-auth/providers/discord";
export const authOptions = {
providers: [
DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET,
}),
],
callbacks: {
async session({ session, token, user }) {
session.user.sub = token.sub;
return session;
},
},
};
export default NextAuth(authOptions);