Skip to content

Commit d1f5c69

Browse files
authored
fix(envvars): use getEnv for isHosted check since it is client-side (#1461)
1 parent c468ecb commit d1f5c69

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

apps/sim/app/api/workspaces/invitations/[invitationId]/route.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ describe('Workspace Invitation [invitationId] API Route', () => {
6666
NEXT_PUBLIC_APP_URL: 'https://test.sim.ai',
6767
BILLING_ENABLED: false,
6868
},
69-
isTruthy: (value: any) =>
69+
isTruthy: (value: string | boolean | number | undefined) =>
7070
typeof value === 'string'
7171
? value.toLowerCase() === 'true' || value === '1'
7272
: Boolean(value),
73+
getEnv: (variable: string) => process.env[variable],
7374
}))
7475

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

apps/sim/lib/environment.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Environment utility functions for consistent environment detection across the application
33
*/
4-
import { env, isTruthy } from './env'
4+
import { env, getEnv, isTruthy } from './env'
55

66
/**
77
* Is the application running in production mode
@@ -22,8 +22,8 @@ export const isTest = env.NODE_ENV === 'test'
2222
* Is this the hosted version of the application
2323
*/
2424
export const isHosted =
25-
env.NEXT_PUBLIC_APP_URL === 'https://www.sim.ai' ||
26-
env.NEXT_PUBLIC_APP_URL === 'https://www.staging.sim.ai'
25+
getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.sim.ai' ||
26+
getEnv('NEXT_PUBLIC_APP_URL') === 'https://www.staging.sim.ai'
2727

2828
/**
2929
* Is billing enforcement enabled

0 commit comments

Comments
 (0)