Skip to content

Commit 81c544f

Browse files
committed
configure environment variables for backend API and server port to enable debugging on a different port
1 parent 4e7c34e commit 81c544f

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

client/.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Backend API URL - the target for all proxy endpoints
2+
BACKEND_API_URL=http://localhost:3001
3+
4+
# Server port for the Vite development server
5+
SERVER_PORT=3000

client/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12+
"@microsoft/applicationinsights-react-js": "^18.3.6",
13+
"@microsoft/applicationinsights-web": "^3.3.6",
1214
"lucide-react": "^0.344.0",
1315
"react": "^18.3.1",
1416
"react-dom": "^18.3.1",
15-
"react-router-dom": "^6.22.3",
16-
"@microsoft/applicationinsights-react-js": "^18.3.6",
17-
"@microsoft/applicationinsights-web": "^3.3.6"
17+
"react-router-dom": "^6.22.3"
1818
},
1919
"devDependencies": {
2020
"@types/react": "^18.3.5",
2121
"@types/react-dom": "^18.3.0",
2222
"@vitejs/plugin-react": "^4.3.1",
2323
"autoprefixer": "^10.4.18",
24+
"dotenv": "^16.4.7",
2425
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
2526
"eslint-plugin-react-refresh": "^0.4.11",
2627
"postcss": "^8.4.35",
2728
"tailwindcss": "^3.4.1",
2829
"vite": "^5.4.2"
2930
}
30-
}
31+
}

client/vite.config.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
33
import { resolve } from 'path';
4+
import dotenv from 'dotenv';
5+
6+
// Load environment variables from .env file
7+
dotenv.config();
8+
9+
// Define backend API target URL that can be easily changed
10+
const BACKEND_API_URL = process.env.BACKEND_API_URL || 'http://localhost:3001';
11+
// Define server port that can be configured via environment variable
12+
const SERVER_PORT = parseInt(process.env.SERVER_PORT || '3000', 10);
413

514
export default defineConfig({
615
plugins: [react()],
@@ -9,14 +18,14 @@ export default defineConfig({
918
},
1019
server: {
1120
host: '0.0.0.0', // Allow access from any IP address
12-
port: 3000, // Port for the Vite server
21+
port: SERVER_PORT, // Port for the Vite server from environment variables
1322
proxy: {
1423
'/v1/mcp': {
15-
target: 'http://localhost:3001',
24+
target: BACKEND_API_URL,
1625
changeOrigin: true
1726
},
1827
'/v1/hub': {
19-
target: 'http://localhost:3001',
28+
target: BACKEND_API_URL,
2029
changeOrigin: true
2130
}
2231
}

package-lock.json

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)