Skip to content

Commit 49b39cb

Browse files
nvm just redirect it
1 parent a72e2f7 commit 49b39cb

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

routes/resources.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,23 +301,17 @@ module.exports = function (express, config) {
301301
proxyUrlDownload(req, res, url);
302302
}
303303

304-
const PROXY_REDIRECT_WHITELIST = [
305-
'https://www.spigotmc.org/resources/',
306-
'https://github.com/',
307-
'https://objects.githubusercontent.com/'
308-
]
309-
310304
function proxyUrlDownload(req, res, url, r = 4) {
311305
console.log("proxying download for " + url)
312306
https.get(url, {
313307
headers: {
314308
'User-Agent': config.userAgent
315309
}
316310
}, resp => {
317-
if (r > 0 && (resp.statusCode === 301 || resp.statusCode === 302 || resp.statusCode === 307) && PROXY_REDIRECT_WHITELIST.some(w => resp.headers.location.startsWith(w))) {
318-
res.set('X-Spiget-Redirect-' + r, resp.headers.location);
311+
if (resp.statusCode === 301 || resp.statusCode === 302 || resp.statusCode === 307) {
319312
console.log("redirecting to " + resp.headers.location);
320-
proxyUrlDownload(req, res, resp.headers.location, r - 1);
313+
res.set('Location', resp.headers.location);
314+
res.status(307).end();
321315
return;
322316
}
323317
console.log(resp.statusCode + " " + url);

0 commit comments

Comments
 (0)