Skip to content

Commit 6cc91ec

Browse files
feat: expose PUBLIC_BASE environment variable and use it to prefix the demo sample JSON path.
1 parent c3b186b commit 6cc91ec

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

ui/src/stores/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const useApiStore = defineStore('api', () => {
8686
// Use explicit string check because the env var might be a string "true" or "false"
8787
// thanks to the defines in vite.config.ts
8888
const isDemo = import.meta.env.VITE_IS_DEMO === 'true';
89-
const url = isDemo ? '/sample.json' : `${apiHost.value}/docs-api/routes`;
89+
const url = isDemo ? `/${import.meta.env.PUBLIC_BASE}/sample.json` : `${apiHost.value}/docs-api/routes`;
9090
const response = await fetch(url);
9191
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
9292
const data = await response.json();

ui/vite.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export default defineConfig({
88
vue(),
99
],
1010
define: {
11-
'import.meta.env.VITE_IS_DEMO': JSON.stringify(process.env.VITE_IS_DEMO)
11+
'import.meta.env.VITE_IS_DEMO': JSON.stringify(process.env.VITE_IS_DEMO),
12+
'import.meta.env.PUBLIC_BASE': JSON.stringify(process.env.PUBLIC_BASE)
1213
},
1314
resolve: {
1415
alias: {

0 commit comments

Comments
 (0)