update nextauth

This commit is contained in:
Ayden Jahola 2024-10-29 13:09:09 +00:00
parent 43b8e55022
commit 01351c7441
No known key found for this signature in database
GPG key ID: 71DD90AE4AE92742
2 changed files with 20 additions and 3 deletions

View file

@ -1,7 +1,7 @@
import NextAuth from "next-auth"; import NextAuth from "next-auth";
import DiscordProvider from "next-auth/providers/discord"; import DiscordProvider from "next-auth/providers/discord";
export const authOptions = { const options = {
providers: [ providers: [
DiscordProvider({ DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID!, clientId: process.env.DISCORD_CLIENT_ID!,
@ -16,6 +16,6 @@ export const authOptions = {
secret: process.env.NEXTAUTH_SECRET, secret: process.env.NEXTAUTH_SECRET,
}; };
const handler = NextAuth(authOptions); const handler = NextAuth(options);
export { handler as GET, handler as POST }; export { handler as GET, handler as POST };

View file

@ -1,7 +1,24 @@
// app/api/discord/channels/route.ts
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import axios from "axios"; import axios from "axios";
import { getServerSession } from "next-auth/next"; 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 DISCORD_API_BASE = "https://discord.com/api/v10";
const BOT_TOKEN = process.env.DISCORD_BOT_TOKEN; const BOT_TOKEN = process.env.DISCORD_BOT_TOKEN;