refactor(vite): add config url#234
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Vite dev-server proxy route to forward /config requests to the local backend.
Changes:
- Added a
/configproxy entry targetinghttp://localhost:8080. - Added request/response/error console logging for the new proxy route (matching existing proxy routes).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| proxy.on('proxyReq', (proxyReq, req) => { | ||
| console.log(`\n[PROXY] ${new Date().toISOString()}`) | ||
| console.log(`Forwarding: ${req.method} ${req.url} -> http://localhost:8080${req.url}`) | ||
| }) | ||
| proxy.on('proxyRes', (proxyRes, req) => { | ||
| console.log(`[PROXY] Response: ${proxyRes.statusCode} ${proxyRes.statusMessage} for ${req.url}`) | ||
| }) | ||
| proxy.on('error', (err, req) => { | ||
| console.log(`\n[PROXY ERROR] ${new Date().toISOString()}`) | ||
| console.log(`Error forwarding ${req.url}:`, err.message) | ||
| }) |
There was a problem hiding this comment.
The new '/config' proxy logs the full request URL (including any query string) on every proxied request/response/error. If '/config' requests can include sensitive values in the URL, this can leak them to console output and also makes dev logs very noisy. Consider gating these logs behind an env flag/log level and/or redacting query strings before logging.
| '/config': { | ||
| target: 'http://localhost:8080', | ||
| changeOrigin: true, | ||
| configure: (proxy) => { | ||
| proxy.on('proxyReq', (proxyReq, req) => { | ||
| console.log(`\n[PROXY] ${new Date().toISOString()}`) | ||
| console.log(`Forwarding: ${req.method} ${req.url} -> http://localhost:8080${req.url}`) | ||
| }) | ||
| proxy.on('proxyRes', (proxyRes, req) => { | ||
| console.log(`[PROXY] Response: ${proxyRes.statusCode} ${proxyRes.statusMessage} for ${req.url}`) | ||
| }) | ||
| proxy.on('error', (err, req) => { | ||
| console.log(`\n[PROXY ERROR] ${new Date().toISOString()}`) | ||
| console.log(`Error forwarding ${req.url}:`, err.message) | ||
| }) | ||
| }, | ||
| }, |
There was a problem hiding this comment.
This adds another proxy entry that duplicates the same configure handler block already repeated across multiple proxy routes in this file. As more routes get added, this duplication increases the risk of inconsistencies and makes edits harder. Consider extracting a shared helper (e.g., a function that returns the common configure implementation) and reusing it for '/config' and the existing routes.
No description provided.