Using Nodejs to Serve an MP4 Video File
<p>I am trying to serve a ~52MB mp4 video file from a nodejs server. Attached below is a screenshot of the code used to serve the file.<a href="https://i.stack.imgur.com/K6Jma.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K6Jma.png" alt="Code used to serve mp4"></a>
I have an object of mime types for static file calls which contains the mime type for mp4.</p>

<p><code>var mimeTypes = {
  html: 'text/html; charset=utf-8',
  jpeg: 'image/jpeg',
  jpg: 'image/jpeg',
  png: 'image/png',
  js: 'text/javascript',
  css: 'text/css',
  mp4: 'video/mp4'
};</code></p>

<p>However, when I try to navigate to the page in chrome, I get the error: </p>

<p><code>GET http://localhost:8888/videos/movie.mp4 net::ERR_INCOMPLETE_CHUNKED_ENCODING</code></p>

<p>Now this same logic (screenshotted above) is used to serve images and css just fine, however it fails miserably when trying to serve the mp4. Looking at the network requests panel in Chrome, I can see that the server responded with a 200 OK status, and served a zero byte file as the video. The range of bytes in the network request also looks suspicious but I don't know enough about HTTP requests to know for sure.
<a href="https://i.stack.imgur.com/CrqLa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CrqLa.png" alt="Request"></a>
<a href="https://i.stack.imgur.com/X13rp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X13rp.png" alt="Request_Abridged"></a></p>

<p>Looking at the stats object (shown below, gotten from fs.lstat), It appears that the file 'knows' how to be split into chunks of 4096 bytes, however I keep getting the incomplete chunked encoding error. I have no antivirus, and tried turning off various settings in Chrome/using another browser but I can't see the video.</p>

<p><code>{"dev":16777220,"mode":33188,"nlink":1,"uid":501,"gid":20,"rdev":0,"blksize":4096,"ino":1070608,"size":51246445,"blocks":100096,"atime":"2016-06-15T23:06:27.000Z","mtime":"2016-06-15T21:41:00.000Z","ctime":"2016-06-15T21:45:56.000Z"}</code></p>

<p>Is there a header I am missing? Am I somehow ending the response too early? I'm clueless right now.</p>