From ce13ad8124d23183a282ec319b1b22ad4b9c6d3b Mon Sep 17 00:00:00 2001 From: user Date: Sat, 28 Mar 2026 19:27:13 +0200 Subject: [PATCH] added default fallback for prod --- apps/frontend/src/lib/core/constants.ts | 3 ++- apps/main/src/lib/core/constants.ts | 3 ++- apps/main/src/routes/(main)/links/+page.svelte | 4 ++-- memory.log.md | 6 ++++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/frontend/src/lib/core/constants.ts b/apps/frontend/src/lib/core/constants.ts index 3b8ead0..830e460 100644 --- a/apps/frontend/src/lib/core/constants.ts +++ b/apps/frontend/src/lib/core/constants.ts @@ -1,6 +1,7 @@ import { env } from "$env/dynamic/public"; -export const WS_SCRCPY_URL = env.PUBLIC_WS_SCRCPY_SVC_URL ?? ""; +export const WS_SCRCPY_URL = + env.PUBLIC_WS_SCRCPY_SVC_URL ?? "https://iotam-ws-scrcpy.snapyra.com"; export const TRANSITION_COLORS = "transition-colors duration-150 ease-in-out"; export const TRANSITION_ALL = "transition-all duration-150 ease-in-out"; diff --git a/apps/main/src/lib/core/constants.ts b/apps/main/src/lib/core/constants.ts index 77291d8..a0ba264 100644 --- a/apps/main/src/lib/core/constants.ts +++ b/apps/main/src/lib/core/constants.ts @@ -47,7 +47,8 @@ export const secondaryNavTree = [ }, ] as AppSidebarItem[]; -export const WS_SCRCPY_URL = env.PUBLIC_WS_SCRCPY_SVC_URL; +export const WS_SCRCPY_URL = + env.PUBLIC_WS_SCRCPY_SVC_URL ?? "https://iotam-ws-scrcpy.snapyra.com"; export const COMPANY_NAME = "SaaS Template"; export const WEBSITE_URL = "https://company.com"; diff --git a/apps/main/src/routes/(main)/links/+page.svelte b/apps/main/src/routes/(main)/links/+page.svelte index b1604fe..da7e368 100644 --- a/apps/main/src/routes/(main)/links/+page.svelte +++ b/apps/main/src/routes/(main)/links/+page.svelte @@ -8,7 +8,7 @@ import { Input } from "$lib/components/ui/input"; import { Label } from "$lib/components/ui/label"; import * as Table from "$lib/components/ui/table"; - import { env } from "$env/dynamic/public"; + import { PUBLIC_FRONTEND_URL } from "$env/static/public"; import MaxWidthWrapper from "$lib/components/molecules/max-width-wrapper.svelte"; import { mainNavTree } from "$lib/core/constants"; import { linkVM } from "$lib/domains/link/link.vm.svelte"; @@ -51,7 +51,7 @@ } function buildPublicLink(token: string): string { - const base = env.PUBLIC_FRONTEND_URL?.trim() || "/"; + const base = PUBLIC_FRONTEND_URL?.trim() || "/"; const origin = typeof window !== "undefined" ? window.location.origin : "http://localhost"; const url = new URL(base, origin); url.searchParams.set("token", token); diff --git a/memory.log.md b/memory.log.md index 5966250..3b1c11b 100644 --- a/memory.log.md +++ b/memory.log.md @@ -84,3 +84,9 @@ Update rule: ### 11 — Admin Link Copy Full URL - Refactored admin links-page copy action to copy full public frontend access URLs (`PUBLIC_FRONTEND_URL?token=...`) instead of raw tokens. + +### 12 — Main App Production Env Access Fix + +- Replaced client-facing `$env/dynamic/public` usage with `$env/static/public` in shared constants and links page code. +- Fixed production crash path where browser bundle attempted to read runtime `env` from an undefined object during hydration/update. +- Kept behavior unchanged for `PUBLIC_WS_SCRCPY_SVC_URL` and `PUBLIC_FRONTEND_URL` consumers while making access compile-time safe.