fix(envvars): use getEnv for isHosted check since it is client-side (#1461)

This commit is contained in:
Waleed
2025-09-26 12:50:51 -07:00
committed by GitHub
parent c468ecbc72
commit d1f5c69e6b
2 changed files with 7 additions and 5 deletions

View File

@@ -66,10 +66,11 @@ describe('Workspace Invitation [invitationId] API Route', () => {
NEXT_PUBLIC_APP_URL: 'https://test.sim.ai',
BILLING_ENABLED: false,
},
isTruthy: (value: any) =>
isTruthy: (value: string | boolean | number | undefined) =>
typeof value === 'string'
? value.toLowerCase() === 'true' || value === '1'
: Boolean(value),
getEnv: (variable: string) => process.env[variable],
}))
mockTransaction = vi.fn()
@@ -388,10 +389,11 @@ describe('Workspace Invitation [invitationId] API Route', () => {
NEXT_PUBLIC_APP_URL: 'https://test.sim.ai',
BILLING_ENABLED: false,
},
isTruthy: (value: any) =>
isTruthy: (value: string | boolean | number | undefined) =>
typeof value === 'string'
? value.toLowerCase() === 'true' || value === '1'
: Boolean(value),
getEnv: (variable: string) => process.env[variable],
}))
vi.doMock('@sim/db/schema', () => ({
workspaceInvitation: { id: 'id' },

View File

@@ -1,7 +1,7 @@
/**
* Environment utility functions for consistent environment detection across the application
*/
import { env, isTruthy } from './env'
import { env, getEnv, isTruthy } from './env'
/**
* Is the application running in production mode
@@ -22,8 +22,8 @@ export const isTest = env.NODE_ENV === 'test'
* Is this the hosted version of the application
*/
export const isHosted =
env.NEXT_PUBLIC_APP_URL === 'https://www.sim.ai' ||
env.NEXT_PUBLIC_APP_URL === 'https://www.staging.sim.ai'
getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai' ||
getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.staging.sim.ai'
/**
* Is billing enforcement enabled