Skip to content

Commit c3b186b

Browse files
feat: create workflow to deploy fixes #2
1 parent 2463f41 commit c3b186b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

ui/src/stores/api.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,14 @@ export const useApiStore = defineStore('api', () => {
8383
async function fetchRoutes() {
8484
isLoadingRoutes.value = true;
8585
try {
86-
const url = import.meta.env.VITE_IS_DEMO ? '/sample.json' : `${apiHost.value}/docs-api/routes`;
86+
// Use explicit string check because the env var might be a string "true" or "false"
87+
// thanks to the defines in vite.config.ts
88+
const isDemo = import.meta.env.VITE_IS_DEMO === 'true';
89+
const url = isDemo ? '/sample.json' : `${apiHost.value}/docs-api/routes`;
8790
const response = await fetch(url);
8891
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
8992
const data = await response.json();
90-
if (import.meta.env.VITE_IS_DEMO) {
93+
if (isDemo) {
9194
fullRoutes.value = data;
9295
// Group by controller for demo
9396
const grouped: { [key: string]: IAPIInfo[] } = {};
@@ -117,7 +120,8 @@ export const useApiStore = defineStore('api', () => {
117120
// Clear previous response
118121
clearResponse();
119122
try {
120-
if (import.meta.env.VITE_IS_DEMO) {
123+
const isDemo = import.meta.env.VITE_IS_DEMO === 'true';
124+
if (isDemo) {
121125
selectedRouteDetails.value = fullRoutes.value.find(r => r.uri === id) || null;
122126
} else {
123127
const response = await fetch(`${apiHost.value}/docs-api/routes/${id}`);

ui/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export default defineConfig({
77
plugins: [
88
vue(),
99
],
10+
define: {
11+
'import.meta.env.VITE_IS_DEMO': JSON.stringify(process.env.VITE_IS_DEMO)
12+
},
1013
resolve: {
1114
alias: {
1215
'@': fileURLToPath(new URL('./src', import.meta.url)),

0 commit comments

Comments
 (0)