Skip to content

Commit a3b2105

Browse files
authored
Merge pull request #25 from data-exp-lab/dev-url-config
configure API base URL for dev and prod
2 parents bf41e33 + 5605531 commit a3b2105

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_API_BASE_URL=http://localhost:5002

.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_API_BASE_URL=

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0-beta.4",
44
"scripts": {
55
"dev": "vite",
6-
"build": "vite build",
6+
"build": "vite build --mode production",
77
"start": "vite preview --port 5173 --host 0.0.0.0",
88
"test": "vitest",
99
"clean": "prettier --write src",
@@ -100,4 +100,4 @@
100100
"last 1 safari version"
101101
]
102102
}
103-
}
103+
}

src/lib/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Backend API configuration
2-
export const API_BASE_URL = '';
2+
export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL;
3+
34

45
// API endpoints
56
export const API_ENDPOINTS = {

start.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,4 @@ fi
4242
# Start the frontend development server
4343
echo "Starting frontend server..."
4444
cd ../..
45-
npm run build
46-
npm start
45+
npm run dev

vite.config.mts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,15 @@ export default defineConfig({
4646
port: process.env.PORT ? parseInt(process.env.PORT) : 5173,
4747
allowedHosts: ["deepgit.onrender.com"]
4848
},
49-
// Disable automatic public directory copying
50-
publicDir: false,
51-
// Manually copy only specific files from public
49+
// Only disable public directory copying during build
50+
publicDir: process.env.NODE_ENV === 'production' ? false : 'public',
5251
build: {
5352
rollupOptions: {
5453
input: {
5554
main: resolve(__dirname, 'index.html'),
5655
},
5756
},
58-
// Copy only specific files from public
57+
// Copy only specific files from public during build
5958
copyPublicDir: true,
6059
assetsInlineLimit: 0,
6160
},

0 commit comments

Comments
 (0)