Avoid duplicate proxy configuration across your application by establishing a single point of proxy setup and leveraging built-in proxy support where available. Multiple proxy configurations can lead to conflicts, inconsistent behavior, and maintenance overhead.
Avoid duplicate proxy configuration across your application by establishing a single point of proxy setup and leveraging built-in proxy support where available. Multiple proxy configurations can lead to conflicts, inconsistent behavior, and maintenance overhead.
Key principles:
Example from the discussions:
// โ Avoid: Multiple proxy configurations
export class MCPOAuthProvider {
private static readonly REDIRECT_PORT = 7777; // Hardcoded port causes conflicts
}
// In another file
const client = new OAuth2Client({
transporter: new Gaxios({ proxy: proxyUrl }) // Duplicate proxy setup
});
// โ Avoid: Redundant proxy setup
if (config.getProxy()) {
// setGlobalDispatcher already called in core/client.ts
}
// โ
Better: Centralized approach
// In core/client.ts - set once globally
setGlobalDispatcher(proxyAgent);
// OAuth2Client automatically reads from environment
const client = new OAuth2Client({
// No manual transporter needed - uses env proxy settings
});
// Use dynamic port allocation
const server = http.createServer();
server.listen(0); // Let Node.js choose available port
This approach ensures consistent proxy behavior across all network requests while avoiding configuration conflicts and reducing maintenance burden.
Enter the URL of a public GitHub repository