From 01351c74413c2da8d6cb930c28ae840584a0064d Mon Sep 17 00:00:00 2001 From: Ayden Jahola Date: Tue, 29 Oct 2024 13:09:09 +0000 Subject: [PATCH] update nextauth --- dashboard/app/api/auth/[...nextauth]/route.ts | 4 ++-- dashboard/app/api/discord/channels/route.ts | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/dashboard/app/api/auth/[...nextauth]/route.ts b/dashboard/app/api/auth/[...nextauth]/route.ts index fba2cab..1895591 100644 --- a/dashboard/app/api/auth/[...nextauth]/route.ts +++ b/dashboard/app/api/auth/[...nextauth]/route.ts @@ -1,7 +1,7 @@ import NextAuth from "next-auth"; import DiscordProvider from "next-auth/providers/discord"; -export const authOptions = { +const options = { providers: [ DiscordProvider({ clientId: process.env.DISCORD_CLIENT_ID!, @@ -16,6 +16,6 @@ export const authOptions = { secret: process.env.NEXTAUTH_SECRET, }; -const handler = NextAuth(authOptions); +const handler = NextAuth(options); export { handler as GET, handler as POST }; diff --git a/dashboard/app/api/discord/channels/route.ts b/dashboard/app/api/discord/channels/route.ts index 4dd0b89..b664735 100644 --- a/dashboard/app/api/discord/channels/route.ts +++ b/dashboard/app/api/discord/channels/route.ts @@ -1,7 +1,24 @@ +// app/api/discord/channels/route.ts + import { NextResponse } from "next/server"; import axios from "axios"; import { getServerSession } from "next-auth/next"; -import { authOptions } from "../../auth/[...nextauth]/route"; +import DiscordProvider from "next-auth/providers/discord"; + +const authOptions = { + providers: [ + DiscordProvider({ + clientId: process.env.DISCORD_CLIENT_ID!, + clientSecret: process.env.DISCORD_CLIENT_SECRET!, + authorization: { + params: { + scope: "identify guilds", + }, + }, + }), + ], + secret: process.env.NEXTAUTH_SECRET, +}; const DISCORD_API_BASE = "https://discord.com/api/v10"; const BOT_TOKEN = process.env.DISCORD_BOT_TOKEN;