File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6262fi
6363
6464echo " Writing to: $env_file "
65-
66- # Remove old compressed versions FIRST (nginx might serve these instead)
67- rm -f " ${env_file} .br" " ${env_file} .gz"
68- echo " Removed old compressed files"
69-
7065echo " export const env=$env_json " > " $env_file "
7166
7267# Verify the file was written
@@ -79,6 +74,24 @@ echo "✓ Successfully generated $env_file"
7974echo " File contents:"
8075cat " $env_file "
8176
77+ # NUKE all pre-compressed files so nginx serves fresh content
78+ echo " Nuking all .br and .gz files..."
79+ find /usr/share/nginx/html/console -type f \( -name " *.br" -o -name " *.gz" \) -delete
80+ echo " ✓ Nuked all compressed files"
81+
82+ # Replace hardcoded PUBLIC_ values in JavaScript files
83+ # Vite inlines env vars at build time, so we need to replace them in the built JS
84+ echo " Replacing hardcoded env values in JavaScript files..."
85+ for var in $public_vars ; do
86+ value=$( printenv " $var " )
87+ echo " Replacing $var in JS files..."
88+
89+ # Find all .js files and replace the value
90+ # Match pattern: "PUBLIC_VAR":"old_value" or 'PUBLIC_VAR':'old_value'
91+ find /usr/share/nginx/html/console -type f -name " *.js" -exec sed -i " s|\" $var \" :\" [^\" ]*\" |\" $var \" :\" $value \" |g" {} \;
92+ done
93+ echo " ✓ Replaced env values in JS files"
94+
8295echo " ========================================="
8396echo " Starting nginx..."
8497echo " ========================================="
Original file line number Diff line number Diff line change 11import { asset , resolve } from '$app/paths' ;
22import type { ResolvedPathname } from '$app/types' ;
3- import { PUBLIC_CONSOLE_PROFILE } from '$env/static /public' ;
3+ import { env } from '$env/dynamic /public' ;
44
55export const enum ProfileMode {
66 STUDIO = 'studio' ,
@@ -114,7 +114,7 @@ export const studio: Profile = {
114114} ;
115115
116116const resolver = $derived ( ( ) => {
117- switch ( PUBLIC_CONSOLE_PROFILE ) {
117+ switch ( env . PUBLIC_CONSOLE_PROFILE ) {
118118 case 'studio' :
119119 return studio ;
120120 default :
Original file line number Diff line number Diff line change 1- import { PUBLIC_APPWRITE_ENDPOINT , PUBLIC_AI_SERVICE_BASE_URL } from '$env/static/public' ;
21import { env } from '$env/dynamic/public' ;
32import { app } from '$lib/stores/app' ;
43import { get } from 'svelte/store' ;
@@ -283,8 +282,8 @@ export async function initImagine(
283282 if ( ! configInitialized ) {
284283 initImagineConfig (
285284 {
286- AI_SERVICE_ENDPOINT : PUBLIC_AI_SERVICE_BASE_URL ,
287- APPWRITE_ENDPOINT : PUBLIC_APPWRITE_ENDPOINT ,
285+ AI_SERVICE_ENDPOINT : env . PUBLIC_AI_SERVICE_BASE_URL ,
286+ APPWRITE_ENDPOINT : env . PUBLIC_APPWRITE_ENDPOINT ,
288287 APPWRITE_SITES_BASE_URL : ''
289288 } ,
290289 {
You can’t perform that action at this time.
0 commit comments