Created
October 8, 2021 22:06
-
-
Save ManUtopiK/70c1aeff5de45980c86209e759cafbd0 to your computer and use it in GitHub Desktop.
fastify read video and return stream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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