import https from 'https'; import fs from 'fs'; const file = fs.createWriteStream("public/hero-bg.jpg"); https.get("https://drive.google.com/uc?export=download&id=1YVWlLN4_6B4aVQ5BMeK72wpJyB4Az5T9", function(response) { if (response.statusCode === 302 || response.statusCode === 303) { https.get(response.headers.location, function(res) { res.pipe(file); }); } else { response.pipe(file); } });