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:
7 files changed
+140
-28
No files matched your search
@@ -6,10 +6,10 @@ import { button, field, input, notice, toast } from '../core/ui.js';
|
||||
|
||||
const ERRORS = {
|
||||
'oauth-not-configured':
|
||||
'La connexion Discord n’est pas configurée. Renseigne `DISCORD_CLIENT_SECRET` et `WEB_PUBLIC_URL`, puis redémarre le bot.',
|
||||
'La connexion Discord n’est pas configurée. Renseigne `DISCORD_CLIENT_SECRET`, puis redémarre le bot.',
|
||||
'state-mismatch': 'La session de connexion a expiré. Réessaie.',
|
||||
'exchange-failed':
|
||||
'Discord a refusé l’échange du code. Vérifie l’URL de redirection déclarée dans le portail.',
|
||||
'Discord a refusé l’échange du code : la redirection déclarée dans le portail ne correspond pas à celle ci-dessous.',
|
||||
'not-a-member': 'Ton compte Discord n’est pas membre du serveur FWS.',
|
||||
'insufficient-level': 'Ton compte n’a pas le rôle Staff, Dev ou Owner sur le serveur.',
|
||||
'missing-code': 'Discord n’a pas renvoyé de code d’autorisation.',
|
||||
@@ -54,6 +54,19 @@ export function render(host, { state }) {
|
||||
'warning',
|
||||
),
|
||||
|
||||
// The redirect is derived from the address in use, so it is the exact
|
||||
// value to paste in the portal — port included.
|
||||
config.redirectUri &&
|
||||
h(
|
||||
'details',
|
||||
{ class: 'muted', style: { textAlign: 'left', width: '100%' } },
|
||||
h('summary', { text: 'Redirection OAuth2 à déclarer dans le Developer Portal' }),
|
||||
h('pre', {}, h('code', { text: config.redirectUri })),
|
||||
h('p', {
|
||||
text: 'Developer Portal → ton application → OAuth2 → Redirects. Elle doit être identique au caractère près, port compris.',
|
||||
}),
|
||||
),
|
||||
|
||||
config.setupAvailable &&
|
||||
h(
|
||||
'div',
|
||||
|
||||
Reference in new issue
Block a user