From 5775084d0a0e0d06209f1a18f2bc4c0c5c9159bc Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Mon, 10 Nov 2025 00:46:11 +0000 Subject: [PATCH] Fix Discord OAuth callback cookie extraction and session handling cgen-67f1518e94174ee99ab95377d5e7ebe8 --- api/discord/oauth/callback.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/discord/oauth/callback.ts b/api/discord/oauth/callback.ts index 1a17ee10..fa1cd0f9 100644 --- a/api/discord/oauth/callback.ts +++ b/api/discord/oauth/callback.ts @@ -89,7 +89,11 @@ export default async function handler(req: any, res: any) { } try { - const redirectUri = "https://aethex.dev/api/discord/oauth/callback"; + // Get the current API base from the request origin + const protocol = req.headers["x-forwarded-proto"] || "https"; + const host = req.headers["x-forwarded-host"] || req.headers.host; + const apiBase = `${protocol}://${host}`; + const redirectUri = `${apiBase}/api/discord/oauth/callback`; // Exchange code for access token const tokenResponse = await fetch(