proxy-middleware: just pass a string

This commit is contained in:
Girish Ramakrishnan
2024-07-30 12:04:35 +02:00
parent 5aa0c57a74
commit a5249102f2
3 changed files with 16 additions and 43 deletions
+1 -3
View File
@@ -33,9 +33,7 @@ function proxy(kind) {
req.url = url.format({ pathname: `/files/${id}/${encodeURIComponent(req.params[0])}`, query: parsedUrl.query }); // params[0] already contains leading '/'
const proxyOptions = url.parse(`http://${result.ip}:3000`);
proxyOptions.rejectUnauthorized = false;
const fileManagerProxy = middleware.proxy(proxyOptions);
const fileManagerProxy = middleware.proxy(`http://${result.ip}:3000`);
fileManagerProxy(req, res, function (error) {
if (!error) return; // note: response was already sent by proxy by this point
+1 -2
View File
@@ -35,8 +35,7 @@ async function proxyToMailContainer(port, pathname, req, res, next) {
parsedUrl.query['access_token'] = addonDetails.token;
req.url = url.format({ pathname, query: parsedUrl.query });
const proxyOptions = url.parse(`http://${addonDetails.ip}:${port}`);
const mailserverProxy = middleware.proxy(proxyOptions);
const mailserverProxy = middleware.proxy(`http://${addonDetails.ip}:${port}`);
req.clearTimeout(); // TODO: add timeout to mail server proxy logic instead of this
mailserverProxy(req, res, function (error) {