Skip to content

Commit

Permalink
🐛 Fix server env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
cermakjiri committed Oct 10, 2024
1 parent b31d254 commit ee142fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions examples/simplewebauthn/src/server/env/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
});
2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ee142fa

Please sign in to comment.