File tree Expand file tree Collapse file tree 5 files changed +18
-17
lines changed
Expand file tree Collapse file tree 5 files changed +18
-17
lines changed Original file line number Diff line number Diff line change 1414 }
1515 encode gzip
1616
17- handle /config.js {
18- header Content-Type "text/javascript"
17+ handle /env.js {
18+ header {
19+ Content-Type text/javascript
20+ }
1921 respond `window.config = {"VITE_SCHEMA_BRANCH":"{$VITE_SCHEMA_BRANCH}", "VITE_POWERBI_URL":"{$VITE_POWERBI_URL}"};`
2022 }
2123 root * /app/dist
2224 encode zstd gzip
2325 file_server
2426 @spa_router {
25- not path /api/* /config .js
27+ not path /api/* /env .js
2628 file {
2729 try_files {path} /index.html
2830 }
Original file line number Diff line number Diff line change 1-
2-
31// eslint-disable-next-line import/prefer-default-export
4- export const env = { ...import . meta. env , ...window . config } ;
2+ export const env = { ...import . meta. env , ...( globalThis . window ? .config ?? { } ) } ;
Original file line number Diff line number Diff line change 55 < link rel ="icon " href ="/favicon.ico " />
66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
77 < title > BCGov Public Code</ title >
8+ < script src ="/env.js "> </ script >
89 </ head >
910 < body >
1011 < div id ="root "> </ div >
Original file line number Diff line number Diff line change 1+ // Runtime configuration loaded before the Vite bundle.
2+ // In production, Caddy serves /env.js and overwrites this response.
3+
4+ window . config = window . config || {
5+ VITE_SCHEMA_BRANCH : "main" ,
6+ VITE_POWERBI_URL : "" ,
7+ } ;
Original file line number Diff line number Diff line change 1- import { defineConfig } from ' vite'
2- import react from ' @vitejs/plugin-react'
1+ import { defineConfig } from " vite" ;
2+ import react from " @vitejs/plugin-react" ;
33
44// https://vite.dev/config/
55export default defineConfig ( {
66 plugins : [ react ( ) ] ,
77 server : {
88 port : 3001 ,
99 proxy : {
10- ' /api' : ' http://localhost:3000' ,
10+ " /api" : " http://localhost:3000" ,
1111 } ,
1212 } ,
13- define : {
14- // Define window.config for build time - will be overridden by Caddy in production
15- 'window.config' : JSON . stringify ( {
16- VITE_SCHEMA_BRANCH : 'main' ,
17- VITE_POWERBI_URL : ''
18- } )
19- }
20- } )
13+ } ) ;
You can’t perform that action at this time.
0 commit comments