From 4df63395ffd4a74a2e04bb1608bd67245b16e202 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Mon, 10 Nov 2025 01:14:58 +0000 Subject: [PATCH] Improve Discord OAuth error message with diagnostic info cgen-c7cd7189c2184212b6303c6eb6c04aff --- api/discord/oauth/callback.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/api/discord/oauth/callback.ts b/api/discord/oauth/callback.ts index 4cd052ae..95616957 100644 --- a/api/discord/oauth/callback.ts +++ b/api/discord/oauth/callback.ts @@ -104,11 +104,18 @@ export default async function handler(req: any, res: any) { if (!authenticatedUserId) { console.error( - "[Discord OAuth] Linking flow but no authenticated user found", + "[Discord OAuth] Linking flow but no authenticated user found - session cookies not present in request", + ); + console.error( + "[Discord OAuth] DIAGNOSTIC: Ensure Discord Dev Portal OAuth2 Redirects includes:", + "https://aethex.dev/api/discord/oauth/callback", + ); + console.error( + "[Discord OAuth] If using custom domain, update the redirect URI accordingly", ); // Redirect to login with a helpful message return res.redirect( - `/login?error=not_authenticated&message=${encodeURIComponent("Please sign in before linking Discord")}`, + `/login?error=session_lost&message=${encodeURIComponent("Your session was lost. Please sign in again and try linking Discord.")}`, ); } }