From 25874991c9867e860da90ae434ee60a381746368 Mon Sep 17 00:00:00 2001 From: Desmond Kyeremeh Date: Wed, 7 Dec 2022 20:10:24 +0000 Subject: [PATCH] Fix empty `publicRuntimeEnvironment` in docker and Kubernetes --- client/consts/consts.ts | 7 ++----- next.config.js | 17 +++++++++-------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/client/consts/consts.ts b/client/consts/consts.ts index 355c95a53..f4ddd2aea 100644 --- a/client/consts/consts.ts +++ b/client/consts/consts.ts @@ -2,11 +2,8 @@ import getConfig from "next/config"; const { publicRuntimeConfig } = getConfig(); -export const DISALLOW_ANONYMOUS_LINKS = - publicRuntimeConfig.DISALLOW_ANONYMOUS_LINKS === "true"; - -export const DISALLOW_REGISTRATION = - publicRuntimeConfig.DISALLOW_REGISTRATION === "true"; +export const { DISALLOW_ANONYMOUS_LINKS } = publicRuntimeConfig; +export const { DISALLOW_REGISTRATION } = publicRuntimeConfig; export enum APIv2 { AuthLogin = "/api/v2/auth/login", diff --git a/next.config.js b/next.config.js index 52d38e977..e327fd4de 100644 --- a/next.config.js +++ b/next.config.js @@ -1,13 +1,14 @@ -const { parsed: localEnv } = require("dotenv").config(); +require("dotenv").config(); +const env = process.env || {}; module.exports = { publicRuntimeConfig: { - CONTACT_EMAIL: localEnv && localEnv.CONTACT_EMAIL, - SITE_NAME: localEnv && localEnv.SITE_NAME, - DEFAULT_DOMAIN: localEnv && localEnv.DEFAULT_DOMAIN, - RECAPTCHA_SITE_KEY: localEnv && localEnv.RECAPTCHA_SITE_KEY, - REPORT_EMAIL: localEnv && localEnv.REPORT_EMAIL, - DISALLOW_ANONYMOUS_LINKS: localEnv && localEnv.DISALLOW_ANONYMOUS_LINKS, - DISALLOW_REGISTRATION: localEnv && localEnv.DISALLOW_REGISTRATION + CONTACT_EMAIL: env.CONTACT_EMAIL, + SITE_NAME: env.SITE_NAME, + DEFAULT_DOMAIN: env.DEFAULT_DOMAIN, + RECAPTCHA_SITE_KEY: env.RECAPTCHA_SITE_KEY, + REPORT_EMAIL: env.REPORT_EMAIL, + DISALLOW_ANONYMOUS_LINKS: env.DISALLOW_ANONYMOUS_LINKS === "true", + DISALLOW_REGISTRATION: env.DISALLOW_REGISTRATION === "true" } };