We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We need a retry mechanism to handle temporary service unavailability and connection failures during proxy requests, something like 'ECONNREFUSED'
Add retry configuration:
Handle specific error cases:
Add response statuses:
const service_proxy_middleware = (target_url) => { const proxy = createProxyMiddleware({ target: "http://localhost:3002/api/v0/endpoint", changeOrigin: true, logger: console, selfHandleResponse: true, retry: { attempts: 3, delay: 1000, factor: 2, retryCondition: (err) => { return ( err.code === "ECONNREFUSED" || err.code === "ECONNRESET" || err.code === "ETIMEDOUT" ); }, }, on: { proxyReq: fixRequestBody, proxyRes: responseInterceptor(save_to_cache), error: (err, req, res) => { if (err.code === "ECONNREFUSED") { res.status(503).json({ status: "error", message: "Service temporarily unavailable / is restarting, please try again", code: "SERVICE_UNAVAILABLE", }); } else { res.status(500).json({ status: "error", message: "Internal server error", code: "PROXY_ERROR", }); } }, }, }); return proxy; };
Related issue: #176
"http-proxy-middleware": "^3.0.3", "node": ">=22.0.0", "express": "^4.21.2"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Retry Mechanism for Failed Proxy Requests
We need a retry mechanism to handle temporary service unavailability and connection failures during proxy requests, something like 'ECONNREFUSED'
Current Behavior
Proposed Changes
Add retry configuration:
Handle specific error cases:
Add response statuses:
Code Example
Related issue: #176
Additional context (optional)
"http-proxy-middleware": "^3.0.3",
"node": ">=22.0.0",
"express": "^4.21.2"
The text was updated successfully, but these errors were encountered: