Skip to content

Commit ea228a6

Browse files
committed
also return version for download
1 parent dc6cc0b commit ea228a6

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

api/download.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ module.exports = (req, res) => {
1919
headers: { ...req.headers, authorization },
2020
})
2121
.then((r) => r.json())
22-
.then((r) => r.versions[r['dist-tags'].latest].dist.tarball)
23-
.then((link) => fetch(link, {
24-
redirect: 'manual',
25-
headers: { authorization },
26-
}))
2722
.then((r) => {
28-
res.status(302);
29-
res.setHeader('location', r.headers.get('location'));
30-
return res.end();
23+
const latest = r['dist-tags'].latest;
24+
const link = r.versions[r['dist-tags'].latest].dist.tarball;
25+
return fetch(link, {
26+
redirect: 'manual',
27+
headers: { authorization },
28+
}).then((r2) => {
29+
res.status(200);
30+
return res.json({
31+
latest,
32+
tarball: r2.headers.get('location'),
33+
});
34+
});
3135
});
3236
};

0 commit comments

Comments
 (0)