fix(web): derive the OAuth2 redirect from the address actually used

`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>
This commit is contained in:
nocodeandClaude Opus 5 committed 2026-09-23 20:12:44 +02:00
1 parent e63d6aa18e
commit 20ff701430
7 files changed
+140 -28

No files matched your search

+2 -2
View File
@@ -99,7 +99,7 @@ const readManaged = () =>
export function registerSettingsRoutes(router) {
router.get(
'/api/settings',
({ actor }) => ({
({ request, actor }) => ({
schema: MANAGED_SETTINGS,
values: readManaged(),
runtime: {
@@ -144,7 +144,7 @@ export function registerSettingsRoutes(router) {
publicUrl: env.web.publicUrl,
sessionTtlHours: env.web.sessionTtlHours,
oauthConfigured: isOauthConfigured(),
redirectUri: redirectUri(),
redirectUri: redirectUri(request),
allowCommandDeploys: env.web.allowCommandDeploys,
allowRestart: env.web.allowRestart,
rateLimitPerMinute: env.web.rateLimitPerMinute,