Skip to content

Commit 592b97c

Browse files
committed
fix(auth): address PR review comments
1 parent 4440001 commit 592b97c

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

apps/sim/lib/auth/auth.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,14 @@ const additionalTrustedOrigins = parseOriginList(env.TRUSTED_ORIGINS, (value) =>
149149
logger.warn('Ignoring invalid entry in TRUSTED_ORIGINS', { value })
150150
)
151151

152-
if (env.NODE_ENV === 'production' && isLocalhostUrl(getBaseUrl())) {
153-
logger.warn(
154-
'NEXT_PUBLIC_APP_URL points to localhost in production. Self-hosted deployments must set NEXT_PUBLIC_APP_URL to the public URL users access (e.g. https://sim.example.com), otherwise auth POST requests from any non-localhost origin will be rejected by trustedOrigins. Set TRUSTED_ORIGINS to allow additional public origins.',
155-
{ baseUrl: getBaseUrl() }
156-
)
152+
if (env.NODE_ENV === 'production') {
153+
const baseUrl = getBaseUrl()
154+
if (isLocalhostUrl(baseUrl)) {
155+
logger.warn(
156+
'NEXT_PUBLIC_APP_URL points to localhost in production. Self-hosted deployments must set NEXT_PUBLIC_APP_URL to the public URL users access (e.g. https://sim.example.com), otherwise auth POST requests from any non-localhost origin will be rejected by trustedOrigins. Set TRUSTED_ORIGINS to allow additional public origins.',
157+
{ baseUrl }
158+
)
159+
}
157160
}
158161

159162
const validStripeKey = env.STRIPE_SECRET_KEY

apps/sim/lib/core/utils/urls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export function getSocketUrl(): string {
184184
if (explicit) return explicit
185185

186186
const browserOrigin = getBrowserOrigin()
187-
if (browserOrigin && !LOCALHOST_HOSTNAMES.has(window.location.hostname)) {
187+
if (browserOrigin && !LOCALHOST_HOSTNAMES.has(new URL(browserOrigin).hostname)) {
188188
return browserOrigin
189189
}
190190

packages/db/scripts/migrate-deployment-versions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// This script is intentionally self-contained for execution in the migrations image.
44
// Do not import from the main app code; duplicate minimal schema and DB setup here.
5+
// Workspace-internal packages (`@sim/*`) are permitted since they ship in the migrations image.
56

67
import { generateId } from '@sim/utils/id'
78
import { sql } from 'drizzle-orm'

0 commit comments

Comments
 (0)