completionId: cgen-db532f6e1d6b4772914ad076e32f23db
cgen-db532f6e1d6b4772914ad076e32f23db
This commit is contained in:
parent
e60015e38c
commit
779a5bffe7
1 changed files with 15 additions and 6 deletions
|
|
@ -751,12 +751,21 @@ export function createServer() {
|
|||
.json({ error: "Discord client ID not configured" });
|
||||
}
|
||||
|
||||
// Get the current API base from the request origin
|
||||
const protocol =
|
||||
req.headers["x-forwarded-proto"] || req.protocol || "https";
|
||||
const host =
|
||||
req.headers["x-forwarded-host"] || req.hostname || req.get("host");
|
||||
const apiBase = `${protocol}://${host}`;
|
||||
// Use the API base URL (should match Discord Dev Portal redirect URI)
|
||||
let apiBase =
|
||||
process.env.VITE_API_BASE ||
|
||||
process.env.API_BASE ||
|
||||
process.env.PUBLIC_BASE_URL ||
|
||||
process.env.SITE_URL;
|
||||
|
||||
if (!apiBase) {
|
||||
// Fallback to request origin if no env var is set
|
||||
const protocol =
|
||||
req.headers["x-forwarded-proto"] || req.protocol || "https";
|
||||
const host =
|
||||
req.headers["x-forwarded-host"] || req.hostname || req.get("host");
|
||||
apiBase = `${protocol}://${host}`;
|
||||
}
|
||||
|
||||
const redirectUri = `${apiBase}/api/discord/oauth/callback`;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue