fix: requete http cause error

This commit is contained in:
Nathan FONTEYNE 2026-07-08 13:56:34 +02:00
parent d159a4ef23
commit d62596abcc

View file

@ -4,10 +4,19 @@ const config = require('../config');
let oidcConfig = null; let oidcConfig = null;
async function initOidc() { async function initOidc() {
const issuerUrl = new URL(config.authentikIssuerUrl);
// Talking to Authentik over its internal Docker hostname (http://) rather
// than its public HTTPS URL is expected (avoids a round trip through
// Traefik) — openid-client refuses plain HTTP by default, so opt back in
// for that case. The flag persists on the resulting Configuration for all
// later calls (token exchange, etc.), not just discovery.
const options = issuerUrl.protocol === 'http:' ? { execute: [client.allowInsecureRequests] } : undefined;
oidcConfig = await client.discovery( oidcConfig = await client.discovery(
new URL(config.authentikIssuerUrl), issuerUrl,
config.oidcClientId, config.oidcClientId,
config.oidcClientSecret config.oidcClientSecret,
undefined,
options
); );
return oidcConfig; return oidcConfig;
} }