From acd3e6d613842b3e9a5625f3a390944f62f7ce10 Mon Sep 17 00:00:00 2001 From: Tameem Asim Date: Wed, 18 Oct 2023 16:28:57 +0500 Subject: [PATCH 1/2] fix: invalid url on main page in self host --- apps/marketing/next.config.js | 2 +- apps/web/next.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/marketing/next.config.js b/apps/marketing/next.config.js index aeb06bdfd..e832dbd7c 100644 --- a/apps/marketing/next.config.js +++ b/apps/marketing/next.config.js @@ -3,7 +3,7 @@ const path = require('path'); const { withContentlayer } = require('next-contentlayer'); require('dotenv').config({ - path: path.join(__dirname, '../../.env.local'), + path: path.join(__dirname, '../../.env'), }); /** @type {import('next').NextConfig} */ diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 92004a3bc..a4e386fd0 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -3,7 +3,7 @@ const path = require('path'); const { version } = require('./package.json'); require('dotenv').config({ - path: path.join(__dirname, '../../.env.local'), + path: path.join(__dirname, '../../.env'), }); /** @type {import('next').NextConfig} */ From b952ed90359e88bc7a7a13e235aee861dda3f5c6 Mon Sep 17 00:00:00 2001 From: Mythie Date: Wed, 18 Oct 2023 23:19:29 +1100 Subject: [PATCH 2/2] fix: support multi env --- apps/marketing/next.config.js | 8 ++++++-- apps/web/next.config.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/marketing/next.config.js b/apps/marketing/next.config.js index e832dbd7c..a997e7b55 100644 --- a/apps/marketing/next.config.js +++ b/apps/marketing/next.config.js @@ -2,8 +2,12 @@ const path = require('path'); const { withContentlayer } = require('next-contentlayer'); -require('dotenv').config({ - path: path.join(__dirname, '../../.env'), +const ENV_FILES = ['.env', '.env.local', `.env.${process.env.NODE_ENV || 'development'}`]; + +ENV_FILES.forEach((file) => { + require('dotenv').config({ + path: path.join(__dirname, `../../${file}`), + }); }); /** @type {import('next').NextConfig} */ diff --git a/apps/web/next.config.js b/apps/web/next.config.js index a4e386fd0..7d1c0811c 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -2,8 +2,12 @@ const path = require('path'); const { version } = require('./package.json'); -require('dotenv').config({ - path: path.join(__dirname, '../../.env'), +const ENV_FILES = ['.env', '.env.local', `.env.${process.env.NODE_ENV || 'development'}`]; + +ENV_FILES.forEach((file) => { + require('dotenv').config({ + path: path.join(__dirname, `../../${file}`), + }); }); /** @type {import('next').NextConfig} */