Fix Discord OAuth callback cookie extraction and session handling

cgen-67f1518e94174ee99ab95377d5e7ebe8
This commit is contained in:
Builder.io 2025-11-10 00:46:11 +00:00
parent 829489ffe1
commit 5775084d0a

View file

@ -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(