fix/optimize wtv-news, wtv-proxy, wtv-register, wtv-search, wtv-setup, wtv-star

This commit is contained in:
zefie
2025-08-12 19:19:23 -04:00
parent d5f41837c0
commit 74ec365ae1
20 changed files with 141 additions and 133 deletions

View File

@@ -1,13 +1,13 @@
minisrv_service_file = true;
const minisrv_service_file = true;
request_is_async = true;
const proxyUrl = minisrv_config.services[service_name].wrp_url;
let proxyUrl = minisrv_config.services[service_name].wrp_url;
if (!proxyUrl.endsWith('/')) {
proxyUrl += '/';
}
// Remove 'service_name:/' from the start of request_url
let forwardPath = request_headers.request_url
const forwardPath = request_headers.request_url
.replace(new RegExp(`^${service_name}:\\/`), '');
// Build the full URL to forward to
@@ -24,12 +24,12 @@ lib.get(targetUrl, (res) => {
headers += `Content-Type: ${res.headers['content-type']}\n`;
}
let data = [];
const data = [];
res.on('data', chunk => data.push(chunk));
res.on('end', () => {
sendToClient(socket, headers, Buffer.concat(data));
});
}).on('error', err => {
var errpage = WTVShared.doErrorPage(400, 'Error fetching image', err.message);
const errpage = wtvshared.doErrorPage(400, 'Error fetching image', err.message);
sendToClient(socket, errpage[0], errpage[1]);
});