fix worker url in prod

This commit is contained in:
Jeff Emmett 2025-09-02 13:16:15 +02:00
parent 9a1846b7bc
commit 190bc7c860
1 changed files with 10 additions and 2 deletions

View File

@ -5,6 +5,13 @@ export default defineConfig(({ mode }) => {
// Load env file based on `mode` in the current working directory. // Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix. // Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), '') const env = loadEnv(mode, process.cwd(), '')
// Debug: Log what we're getting
console.log('🔧 Vite config - Environment variables:')
console.log('Mode:', mode)
console.log('process.env.VITE_TLDRAW_WORKER_URL:', process.env.VITE_TLDRAW_WORKER_URL)
console.log('env.VITE_TLDRAW_WORKER_URL:', env.VITE_TLDRAW_WORKER_URL)
console.log('Final worker URL:', process.env.VITE_TLDRAW_WORKER_URL || env.VITE_TLDRAW_WORKER_URL)
return { return {
envPrefix: ["VITE_"], envPrefix: ["VITE_"],
@ -24,8 +31,9 @@ export default defineConfig(({ mode }) => {
}, },
}, },
define: { define: {
__WORKER_URL__: JSON.stringify(env.VITE_TLDRAW_WORKER_URL), // Use process.env for production builds, fallback to .env files for development
__DAILY_API_KEY__: JSON.stringify(env.VITE_DAILY_API_KEY) __WORKER_URL__: JSON.stringify(process.env.VITE_TLDRAW_WORKER_URL || env.VITE_TLDRAW_WORKER_URL),
__DAILY_API_KEY__: JSON.stringify(process.env.VITE_DAILY_API_KEY || env.VITE_DAILY_API_KEY)
} }
} }
}) })