1
0
mirror of https://github.com/zumbiepig/MineXLauncher.git synced 2025-06-08 08:04:49 +00:00
This commit is contained in:
zumbiepig 2024-09-15 17:19:47 -07:00
parent 3c2e448aba
commit 4ad900683f
No known key found for this signature in database
GPG Key ID: 17C891BE28B953DE

View File

@ -35,10 +35,8 @@ app.use((req, res) => {
if (cached && Date.now() - cached.lastFetched < cacheLifetime) {
requestCounter.set(req.url, (requestCounter.get(req.url) ?? 0) + 1);
res.writeHead(cached.statusCode, cached.headers).end(cached.data);
return;
}
}
} else {
const proxyReq = https.request(
{
hostname: proxyHostname,
@ -91,13 +89,21 @@ app.use((req, res) => {
},
);
proxyReq.on('error', () =>
proxyReq.on('error', () => {
if (req.method === 'GET' && cache.has(req.url)) {
const cached = cache.get(req.url);
if (cached) {
requestCounter.set(req.url, (requestCounter.get(req.url) ?? 0) + 1);
res.writeHead(cached.statusCode, cached.headers).end(cached.data);
}
} else
res
.writeHead(500, { 'Content-Type': 'text/plain' })
.end('500 Internal Server Error'),
);
.end('500 Internal Server Error');
});
proxyReq.end();
}
});
app.listen(PORT, () =>