From e63e5bae4e32df43cfdab473995d324d2ea671f1 Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Fri, 3 Dec 2021 14:04:30 +0800 Subject: [PATCH] feat(core): support trusting TLS offloading proxies config --- packages/core/src/env/consts.ts | 3 +++ packages/core/src/index.ts | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/src/env/consts.ts b/packages/core/src/env/consts.ts index 642778e75..87f63dc2e 100644 --- a/packages/core/src/env/consts.ts +++ b/packages/core/src/env/consts.ts @@ -5,3 +5,6 @@ export const isProduction = getEnv('NODE_ENV') === 'production'; export const port = Number(getEnv('PORT', '3001')); export const mountedApps = Object.freeze(['api', 'oidc']); export const developmentUserId = getEnv('DEVELOPMENT_USER_ID'); + +// Trusting TLS offloading proxies: https://github.com/panva/node-oidc-provider/blob/main/docs/README.md#trusting-tls-offloading-proxies +export const trustingTlsOffloadingProxies = getEnv('TRUSTING_TLS_OFFLOADING_PROXIES') === 'true'; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 6bf702547..e462da36c 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -7,9 +7,12 @@ import Koa from 'koa'; dotenv.config(); import initApp from './app/init'; +import { trustingTlsOffloadingProxies } from './env/consts'; import initI18n from './i18n/init'; -const app = new Koa(); +const app = new Koa({ + proxy: trustingTlsOffloadingProxies, +}); (async () => { try {