Sorry for any inconvenience with the question title, but I don't know how to describe issue.
I have the following code to fecth remote video and pipe it to the response (play it in the browser using html5 video tag):
const express = require('express')
//url: https://www.example.com/video.mp4
const http = require('https')
const app = express()
app.get('/', (req, res) => {
http.get(url, (httpRes) => {
httpRes.pipe(res)
})
})
And I also tried using got
npm module:
got.stream(url).pipe(res)
the problem is: both methods work just fine if the video duration was not that long (IE 3 minutes), but if it was (IE more than 35 minutes ) it won't fetch the whole video, instead it gives me the first 2:54 minutes.
What could be the problem? and what can I do to fix it? Thank you all for any kind of help.
EDIT:
MY FULL CODE:
const express = require('express')
const url = 'https://www.example.com/video.mp4'
const fs = require('fs')
const http = require('https')
const app = express()
const port = 3000
// the main request is made by the client to this endopoint '/'
app.get('/', (req, res) => {
//the server responds by sending 'player.html' file
res.sendFile(__dirname + '/player.html')
})
// this request is made by the <video> tag in 'player.html'
app.get('/video', (req, res) => {
http.get(url, (response) => {
response.pipe(res)
})
player.html file:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
</head>
<body>
<video id="videoPlayer" controls width="100%" height="auto">
<source src='/video' type="video/mp4">
</video>
</body>
</html>