Skip to content

Instantly share code, notes, and snippets.

@ManUtopiK
Created October 8, 2021 22:06
Show Gist options
  • Select an option

  • Save ManUtopiK/70c1aeff5de45980c86209e759cafbd0 to your computer and use it in GitHub Desktop.

Select an option

Save ManUtopiK/70c1aeff5de45980c86209e759cafbd0 to your computer and use it in GitHub Desktop.
fastify read video and return stream
fastify.get('/api/watch', async function (req, res) {
const mp4Url = "https://download1319.mediafire.com/ky961ln87icg/cl1lndr4pyy4cv4/aAbnw92_460svav1+%281%29.mp4";
const response = await axios.get(mp4Url, {
responseType: "stream",
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
},
});
return res
.send(response.data)
.header("Content-Type", response.headers["content-type"]);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment