Add enable write env to frontend and rename envs common to front and back with VITE_, so that same env works for both

This commit is contained in:
ShootingStar91
2024-07-16 10:05:37 +03:00
parent d1b52f8bf1
commit 7ad8ea768b
3 changed files with 4 additions and 5 deletions
+1 -2
View File
@@ -17,6 +17,5 @@ LOG_DB_NAME: now_log_test
COORDINATOR: TEST-SU
ENABLE_WRITE: true
RUNNING_ENV: dev
VITE_ENABLE_WRITE: true
VITE_RUNNING_ENV: dev
+2 -2
View File
@@ -12,11 +12,11 @@ export const USER_CREATION_SECRET = process.env.USER_CREATION_SECRET as string
prod = production with real data
*/
const allowedRunningEnvs = ['dev', 'staging', 'prod'] as const
export const RUNNING_ENV = process.env.RUNNING_ENV as (typeof allowedRunningEnvs)[number]
export const RUNNING_ENV = process.env.VITE_RUNNING_ENV as (typeof allowedRunningEnvs)[number]
if (!allowedRunningEnvs.includes(RUNNING_ENV)) throw new Error('Invalid RUNNING_ENV')
// Enable write operations. If this is not set to 'true', all write (create, update, delete) operations except for allowed ones (like user/login) are disabled.
export const ENABLE_WRITE = process.env.ENABLE_WRITE === 'true'
export const ENABLE_WRITE = process.env.VITE_ENABLE_WRITE === 'true'
export const DB_CONNECTION_LIMIT = (process.env.DB_CONNECTION_LIMIT as string) ?? '10'
export const NOW_DB_NAME = process.env.NOW_DB_NAME as string
+1 -1
View File
@@ -1,3 +1,3 @@
export const BACKEND_URL = (import.meta.env.VITE_BACKEND_URL as string | undefined) ?? 'http://localhost:4000/'
export const ENV = import.meta.env.VITE_RUNNING_ENV as 'dev' | 'staging' | 'prod'
export const ENABLE_WRITE = import.meta.env.ENABLE_WRITE === 'true'
export const ENABLE_WRITE = import.meta.env.VITE_ENABLE_WRITE === 'true'