completionId: cgen-9c165472fa87466c8c034000852c961f

cgen-9c165472fa87466c8c034000852c961f
This commit is contained in:
Builder.io 2025-11-16 08:17:20 +00:00
parent cb6cc15aef
commit 4c180012b8

View file

@ -12,12 +12,9 @@ export default function handler(req: any, res: any) {
return res.status(500).json({ error: "Discord client ID not configured" });
}
// Get the current API base from the request origin
const protocol =
req.headers["x-forwarded-proto"] || req.headers.protocol || "https";
const host = req.headers["x-forwarded-host"] || req.headers.host;
const apiBase = `${protocol}://${host}`;
// Use the main API base domain to ensure the redirect_uri matches the registered one
// This is critical because Discord OAuth requires exact match of redirect_uri
const apiBase = process.env.VITE_API_BASE || "https://aethex.dev";
const redirectUri = `${apiBase}/api/discord/oauth/callback`;
// Get the state from query params (can be a JSON string with action and redirectTo)