dybnamic env

This commit is contained in:
Ariel Weinberger
2025-11-16 23:12:36 -06:00
parent 3799b12a2d
commit 88bc820dfb
3 changed files with 22 additions and 10 deletions
+18 -5
View File
@@ -62,11 +62,6 @@ else
fi
echo "Writing to: $env_file"
# Remove old compressed versions FIRST (nginx might serve these instead)
rm -f "${env_file}.br" "${env_file}.gz"
echo " Removed old compressed files"
echo "export const env=$env_json" > "$env_file"
# Verify the file was written
@@ -79,6 +74,24 @@ echo "✓ Successfully generated $env_file"
echo "File contents:"
cat "$env_file"
# NUKE all pre-compressed files so nginx serves fresh content
echo "Nuking all .br and .gz files..."
find /usr/share/nginx/html/console -type f \( -name "*.br" -o -name "*.gz" \) -delete
echo "✓ Nuked all compressed files"
# Replace hardcoded PUBLIC_ values in JavaScript files
# Vite inlines env vars at build time, so we need to replace them in the built JS
echo "Replacing hardcoded env values in JavaScript files..."
for var in $public_vars; do
value=$(printenv "$var")
echo " Replacing $var in JS files..."
# Find all .js files and replace the value
# Match pattern: "PUBLIC_VAR":"old_value" or 'PUBLIC_VAR':'old_value'
find /usr/share/nginx/html/console -type f -name "*.js" -exec sed -i "s|\"$var\":\"[^\"]*\"|\"$var\":\"$value\"|g" {} \;
done
echo "✓ Replaced env values in JS files"
echo "========================================="
echo "Starting nginx..."
echo "========================================="
+2 -2
View File
@@ -1,6 +1,6 @@
import { asset, resolve } from '$app/paths';
import type { ResolvedPathname } from '$app/types';
import { PUBLIC_CONSOLE_PROFILE } from '$env/static/public';
import { env } from '$env/dynamic/public';
export const enum ProfileMode {
STUDIO = 'studio',
@@ -114,7 +114,7 @@ export const studio: Profile = {
};
const resolver = $derived(() => {
switch (PUBLIC_CONSOLE_PROFILE) {
switch (env.PUBLIC_CONSOLE_PROFILE) {
case 'studio':
return studio;
default:
+2 -3
View File
@@ -1,4 +1,3 @@
import { PUBLIC_APPWRITE_ENDPOINT, PUBLIC_AI_SERVICE_BASE_URL } from '$env/static/public';
import { env } from '$env/dynamic/public';
import { app } from '$lib/stores/app';
import { get } from 'svelte/store';
@@ -283,8 +282,8 @@ export async function initImagine(
if (!configInitialized) {
initImagineConfig(
{
AI_SERVICE_ENDPOINT: PUBLIC_AI_SERVICE_BASE_URL,
APPWRITE_ENDPOINT: PUBLIC_APPWRITE_ENDPOINT,
AI_SERVICE_ENDPOINT: env.PUBLIC_AI_SERVICE_BASE_URL,
APPWRITE_ENDPOINT: env.PUBLIC_APPWRITE_ENDPOINT,
APPWRITE_SITES_BASE_URL: ''
},
{