mirror of
https://github.com/zumbiepig/MineXLauncher.git
synced 2025-06-08 08:04:49 +00:00
.
This commit is contained in:
parent
3c2e448aba
commit
4ad900683f
@ -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, () =>
|
||||
|
Loading…
x
Reference in New Issue
Block a user