fix: auth errors

- Fixes Discord not logging in
- Also shows the login page but with an error message for future errors
This commit is contained in:
trafficlunar 2026-10-24 00:30:01 +01:00
parent f0cf08f2a4
commit b2e1ab2d2f
6 changed files with 64 additions and 46 deletions

View file

@ -0,0 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
export function GET(req: NextRequest) {
const target = new URL("/login", process.env.FRONTEND_URL ?? "http://localhost:5173");
target.search = req.nextUrl.search; // keeps ?error=
return NextResponse.redirect(target);
}

View file

@ -8,7 +8,7 @@ import { prisma } from "@/lib/prisma";
export const { handlers, signIn, signOut, auth } = NextAuth({
adapter: PrismaAdapter(prisma),
providers: [Discord, Github({ issuer: "https://github.com/login/oauth" }), Google],
providers: [Discord({ issuer: "https://discord.com" }), Github({ issuer: "https://github.com/login/oauth" }), Google],
trustHost: true,
cookies: {
sessionToken: {
@ -26,6 +26,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
strategy: "database",
maxAge: 30 * 24 * 60 * 60,
},
pages: { signIn: "/login", error: "/login" },
callbacks: {
async signIn({ user }) {
const blacklist = process.env.BLACKLISTED_EMAILS ? process.env.BLACKLISTED_EMAILS.split(",").map((item) => item.trim().toLowerCase()) : [];