Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Ensure backend-proxied connections are closed correctly on errors.

nzbdav-dev9a66a2494124
diff --git a/frontend/server/app.ts b/frontend/server/app.ts
index 86d93c7e..7efd66bc 100644
--- a/frontend/server/app.ts
+++ b/frontend/server/app.ts
@@ -18,6 +18,15 @@ export const initializeWebsocketServer = websocketServer.initialize;
const forwardToBackend = createProxyMiddleware({
target: process.env.BACKEND_URL,
changeOrigin: true,
+ on: {
+ proxyRes: (proxyRes, req, res) => {
+ proxyRes.on('close', () => {
+ if (!res.writableEnded) {
+ res.end();
+ }
+ });
+ },
+ },
});
const setApiKeyForAuthenticatedRequests = async (req: express.Request) => {