From ee142fa20feca02c1ccfd649141de3aeae4e7afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C4=8Cerm=C3=A1k?= Date: Thu, 10 Oct 2024 11:58:51 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20server=20env=20vars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simplewebauthn/src/server/env/index.ts | 20 ++++++++++++------- turbo.json | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/simplewebauthn/src/server/env/index.ts b/examples/simplewebauthn/src/server/env/index.ts index 29347b5..22493dd 100644 --- a/examples/simplewebauthn/src/server/env/index.ts +++ b/examples/simplewebauthn/src/server/env/index.ts @@ -1,13 +1,15 @@ import dotenv from 'dotenv'; import { z } from 'zod'; -const envs = dotenv.config({ - path: '.env.server', - processEnv: {}, -}); +if (process.env.NODE_ENV !== 'production') { + const envs = dotenv.config({ + path: '.env.server', + processEnv: {}, + }); -if (envs.error) { - throw new Error(envs.error.message); + if (envs.error) { + throw new Error(envs.error.message); + } } export const env = z @@ -16,4 +18,8 @@ export const env = z FIREBASE_PRIVATE_KEY: z.string(), FIREBASE_CLIENT_EMAIL: z.string(), }) - .parse(envs.parsed); + .parse({ + FIREBASE_PROJECT_ID: process.env.FIREBASE_PROJECT_ID, + FIREBASE_PRIVATE_KEY: process.env.FIREBASE_PRIVATE_KEY, + FIREBASE_CLIENT_EMAIL: process.env.FIREBASE_CLIENT_EMAIL, + }); diff --git a/turbo.json b/turbo.json index c25649c..625c38c 100644 --- a/turbo.json +++ b/turbo.json @@ -7,7 +7,7 @@ "build": { "outputs": ["dist/**", ".next/**", "!.next/cache/**"], "dependsOn": ["cir-dep", "format", "lint", "^build"], - "inputs": ["$TURBO_DEFAULT$", ".env.local", ".env", ".env.local.server"] + "inputs": ["$TURBO_DEFAULT$", ".env.local", ".env", ".env.server"] }, "lint": { "cache": true,