import { AuthOptions } from "next-auth"; import DiscordProvider from 'next-auth/providers/discord'; import jwt from 'jsonwebtoken'; export const authOptions: AuthOptions = { providers: [ DiscordProvider({ clientId: process.env.DISCORD_CLIENT_ID!, clientSecret: process.env.DISCORD_CLIENT_SECRET!, }), ], secret: process.env.NEXTAUTH_SECRET, session: { strategy: "jwt", }, callbacks: { async jwt({ token, account, user }) { if (account) { token.accessToken = jwt.sign( { userId: user?.id, provider: account.provider, timestamp: Date.now(), }, process.env.NEXTAUTH_SECRET!, { expiresIn: "1h" } ); } return token; }, async session({ session, token }) { session.accessToken = token.accessToken; return session; }, }, };