From 448293d6ac5188ee18ffc3a68754d618f308ff7a Mon Sep 17 00:00:00 2001 From: metal Date: Fri, 31 Mar 2023 16:35:35 +0000 Subject: [PATCH] env fixes for web platform hosting Signed-off-by: GitHub --- backend/src/env.ts | 4 ++-- dashboard/webpack.config.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/env.ts b/backend/src/env.ts index c1712a3e..3d98506d 100644 --- a/backend/src/env.ts +++ b/backend/src/env.ts @@ -52,11 +52,11 @@ const envType = z.object({ DB_DATABASE: z.string().optional().default("zeppelin"), }); -let toValidate = {}; +let toValidate = { ...process.env }; const envPath = path.join(rootDir, ".env"); if (fs.existsSync(envPath)) { const buf = fs.readFileSync(envPath); - toValidate = dotenv.parse(buf); + toValidate = { ...toValidate, ...dotenv.parse(buf) }; } export const env = envType.parse(toValidate); diff --git a/dashboard/webpack.config.js b/dashboard/webpack.config.js index 2ae878ca..c64390ab 100644 --- a/dashboard/webpack.config.js +++ b/dashboard/webpack.config.js @@ -3,6 +3,7 @@ const VueLoaderPlugin = require("vue-loader/lib/plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const DotenvPlugin = require("dotenv-webpack"); const merge = require("webpack-merge"); +const webpack = require("webpack"); const targetDir = path.normalize(path.join(__dirname, "dist")); @@ -162,6 +163,8 @@ let config = { }, }; +if (process.env.NODE_ENV === "web") config.plugins.push(new webpack.EnvironmentPlugin(['NODE_ENV', 'API_URL'])); + if (process.env.NODE_ENV === "production") { config = merge(config, { mode: "production",