completionId: cgen-0c318fecb8884accbe9298eddad0a8f7

cgen-0c318fecb8884accbe9298eddad0a8f7
This commit is contained in:
Builder.io 2025-11-16 08:17:23 +00:00
parent 4c180012b8
commit 51649d6ae8

View file

@ -116,10 +116,9 @@ export default async function handler(req: any, res: any) {
}
try {
// 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}`;
// 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`;
// Exchange code for access token