-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
57 lines (56 loc) · 2.01 KB
/
vite.config.ts
File metadata and controls
57 lines (56 loc) · 2.01 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
proxy: {
'/api/news': {
target: 'https://news-server-953974838707.asia-northeast1.run.app/',
changeOrigin: true,
secure: true,
rewrite: (path) => path.replace(/^\/api\/news/, '/api/news'),
configure: (proxy, options) => {
proxy.on('proxyReq', (proxyReq, req, res) => {
if (process.env.NODE_ENV !== 'production') {
console.log('🔄 News API Proxy Request:', req.method, req.url);
console.log('📨 News API Headers:', req.headers);
}
});
proxy.on('proxyRes', (proxyRes, req, res) => {
if (process.env.NODE_ENV !== 'production') {
console.log('📡 News API Proxy Response:', proxyRes.statusCode, req.url);
}
});
}
},
'/api': {
//target: 'https://exch-sim-953974838707.asia-northeast1.run.app/',
target: 'http://localhost:8080',
changeOrigin: true,
secure: false,
ws: true,
configure: (proxy, options) => {
proxy.on('proxyReq', (proxyReq, req, res) => {
console.log('🔄 Main API Proxy Request:', req.method, req.url);
console.log('📨 Main API Headers:', req.headers);
console.log('🎯 Target:', options.target);
});
proxy.on('proxyRes', (proxyRes, req, res) => {
console.log('📡 Main API Proxy Response:', proxyRes.statusCode, req.url);
if (proxyRes.statusCode >= 400) {
console.error('❌ Proxy Error Response:', {
status: proxyRes.statusCode,
url: req.url,
headers: proxyRes.headers
});
}
});
proxy.on('error', (err, req, res) => {
console.error('💥 Proxy Error:', err.message, req.url);
});
}
}
}
}
})