-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
41 lines (36 loc) · 1.7 KB
/
vite.config.js
File metadata and controls
41 lines (36 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// frontend/vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path'; // Import path module
import { fileURLToPath } from 'url'; // Import fileURLToPath
// Get the directory name of the current module file
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Log the resolved .env directory for debugging
console.log('Vite config: envDir resolved to:', path.resolve(__dirname, '..'));
// Log the value of VITE_API_URL as seen by Node.js when vite.config.js is loaded
console.log('Vite config: process.env.VITE_API_URL (at config load):', process.env.VITE_API_URL);
export default defineConfig({
plugins: [react()],
server: {
host: true,
proxy: {
'/api': {
target: 'http://localhost:10000', // यह आपके बैकएंड सर्वर का URL है
changeOrigin: true, // होस्ट हेडर को टारगेट URL पर बदलता है
rewrite: (path) => path.replace(/^\/api/, '/api'), // सुनिश्चित करें कि /api पथ बना रहे
},
},
port: 5173, // Vite का डिफ़ॉल्ट पोर्ट
},
// We'll remove envDir as we're explicitly setting the env var in package.json
// envDir: path.resolve(__dirname, '..'), // REMOVED THIS LINE
optimizeDeps: {
exclude: ['lucide-react'],
},
// *** CRITICAL CHANGE: Re-added 'define' block to explicitly pass the env var ***
// This ensures VITE_API_URL is embedded into the client bundle.
define: {
'import.meta.env.VITE_API_URL': JSON.stringify(process.env.VITE_API_URL || 'http://localhost:10000'),
},
});