Skip to content

Commit 5624adf

Browse files
committed
fix: powerbi url setup
1 parent 4b91e6d commit 5624adf

File tree

4 files changed

+10
-31
lines changed

4 files changed

+10
-31
lines changed

frontend/env.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
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 ?? {}) };

frontend/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
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>

frontend/public/env.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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+
};

frontend/vite.config.js

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,11 @@ import react from "@vitejs/plugin-react";
33

44
// https://vite.dev/config/
55
export default defineConfig({
6-
plugins: [
7-
{
8-
name: "build-html",
9-
apply: "build",
10-
transformIndexHtml: (html) => {
11-
return {
12-
html,
13-
tags: [
14-
{
15-
tag: "script",
16-
attrs: {
17-
src: "/env.js",
18-
},
19-
injectTo: "head",
20-
},
21-
],
22-
};
23-
},
24-
},
25-
react(),
26-
],
6+
plugins: [react()],
277
server: {
288
port: 3001,
299
proxy: {
3010
"/api": "http://localhost:3000",
3111
},
3212
},
33-
define: {
34-
// Define window.config for build time - will be overridden by Caddy in production
35-
"window.config": JSON.stringify({
36-
VITE_SCHEMA_BRANCH: "main",
37-
VITE_POWERBI_URL: "",
38-
}),
39-
},
4013
});

0 commit comments

Comments
 (0)