From 4a542eaf166919e67be16ea7b7dee7f415030b36 Mon Sep 17 00:00:00 2001 From: Alexandre KIENTZ Date: Wed, 3 Dec 2025 21:03:31 +0100 Subject: [PATCH] first commit --- config.json | 14 +++++++------- server.js | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/config.json b/config.json index 48dc619..1938590 100644 --- a/config.json +++ b/config.json @@ -1,13 +1,13 @@ [ { - "id": "app1", - "pathPrefix": "/app1", - "upstream": "http://localhost:8081", + "id": "radarr", + "pathPrefix": "/radarr", + "upstream": "http://10.1.4.2:7878", "oidc": { - "issuer": "https://keycloak.example/auth/realms/myrealm", - "client_id": "app1-client", - "client_secret": "REPLACE_WITH_SECRET", - "redirect_uri": "http://localhost:3000/callback/app1" + "issuer": "https://sso.leskientz.ovh/realms/master", + "client_id": "proxyopenid", + "client_secret": "biM7eaxeCrzI2OnAoVHOAWe1n2ptAdhz", + "redirect_uri": "https://secure.k2r.ovh/callback/app1" } } ] diff --git a/server.js b/server.js index 042a1ed..0119d5b 100644 --- a/server.js +++ b/server.js @@ -5,7 +5,18 @@ const bodyParser = require('body-parser'); const { createProxyMiddleware } = require('http-proxy-middleware'); const path = require('path'); const fs = require('fs'); -const { Issuer, generators } = require('openid-client'); + +// Import openid-client in a way that works with both CJS and ESM builds. +let Issuer, generators; +try { + const oc = require('openid-client'); + // package may export under .default for some ESM->CJS interop + Issuer = oc.Issuer || (oc.default && oc.default.Issuer); + generators = oc.generators || (oc.default && oc.default.generators); +} catch (err) { + // don't crash here — we'll log and skip OIDC setup later + console.warn('openid-client not available via require():', err.message); +} const app = express(); const PORT = process.env.PORT || 3000; @@ -139,6 +150,10 @@ if (fs.existsSync(cfgPath)) { const oidcClients = {}; async function setupOidc() { + if (!Issuer) { + console.warn('openid-client Issuer is unavailable; skipping OIDC setup.'); + return; + } for (const host of HOSTS) { if (host.oidc && host.oidc.issuer) { try {