`WEB_PUBLIC_URL` was the only source of the `redirect_uri`, so a hosting panel or a proxy publishing the dashboard on another port produced a link Discord refuses, with nothing on screen pointing at the port mismatch. The browser's own origin is what Discord compares against, so the redirect now comes from the request, honouring `X-Forwarded-Host` and `X-Forwarded-Proto` when a proxy sits in front. `WEB_PUBLIC_URL` stays as the fallback for links built outside a request, and the sign-in page prints the exact value to declare in the portal. The `Secure` cookie flag follows the same rule: announcing HTTPS in the configuration while serving plain HTTP made the browser drop the session. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>