Overview
This article explains how to configure the express-openid-connect library to use a web proxy.
Applies To
- express-openid-connect Library
- Web Proxy
Solution
The express-openid-connect SDK supports configuring a custom Agent as of version 2.14 using the httpAgent parameter.
Combined with the proxy-agent library it is possible to set a custom web proxy.
Here is an example:
import { ProxyAgent } from 'proxy-agent';
const { auth } = require('express-openid-connect');
// The correct proxy `Agent` implementation to use will be determined
// via the `http_proxy` / `https_proxy` / `no_proxy` / etc. env vars
const agent = new ProxyAgent();
app.use(
auth({
issuerBaseURL: 'https://YOUR_DOMAIN',
baseURL: 'https://YOUR_APPLICATION_ROOT_URL',
clientID: 'YOUR_CLIENT_ID',
secret: 'LONG_RANDOM_STRING',
idpLogout: true,
httpAgent: agent,
})
);