
Fixing AI code, over-engineering JavaScript, and more: discover what’s new in The Replay, LogRocket’s newsletter for dev and engineering leaders, in the December 10th issue.

TOON is a lightweight format designed to reduce token usage in LLM prompts. This post breaks down how it compares to JSON, where the savings come from, and when it actually helps.

Andrew Evans, principal engineer and tech lead at CarMax discusses five ways to fix AI-generated code and help you debug, test, and ship safely.

This tutorial walks through recreating Apple’s Liquid Glass UI on the web using SVG filters, CSS, and React. You’ll learn how to build refraction and reflection effects with custom displacement and specular maps, and how to balance performance and accessibility when using advanced filter pipelines.
Would you be interested in joining LogRocket's developer community?
Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.
Sign up now
10 Replies to "Build a video streaming server with Node.js"
Typo ?
npm install –save epress nodemon
Should be ?
npm install –save express nodemon
Thank you for pointing this out! The typo has been fixed.
But `express.static()` supports ranged requests out of the box.
Looks like all you needed was a middleware that rejects non-ranged requests, although that detail seems a bit questionable, as not all browsers use ranged requests to play video.
(If this was intended as just an exercise, the article probably should explain that.)
Not sure but I I think that if you put a `return` under `res.status(400).send(“Requires Range header”);` you can avoid this error that I get“`Cannot read properties of undefined (reading ‘replace’)
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client“` when I try to access directly `/video`
i have try but in mobile client it is not work that use video to receive stream, Is any body else face the same issue like me
Is there a way to stream a camera link (cctv) or network stream (droidcam) instead of a fixed video.
This guide is great and all, but you are not handling the range header correctly. As it stands, videos will not load on iPhones, iPads, certain TVs etc. Follow the guide above, and then modify the code to include this: https://medium.com/@vishal1909/how-to-handle-partial-content-in-node-js-8b0a5aea216
I would like to serve a 10 second .mp4 video, and after the stream completes, I would like to redirect to a static html page. Problem I get is that when video completes, I can’t figure out how to then serve the .html file. I’m trying to do this with the Express package. Is there a way for one node.js file server to serve a .mp4 file then an .html file?
Yes you can use event emitter and emit the ‘end’ event where you can redirect the user to html file.
Really helpfull, thanks for sharing. You should run it as https server since http is not really used anymore.
/* your CONSTs block */
// https server CONSTs
const privateKey = fs.readFileSync(‘path/to/your_key_file.ext’, ‘utf8’);
const certificate = fs.readFileSync(‘path/to/your_cert_file.ext’, ‘utf8’);
const credentials = {key: privateKey, cert: certificate};
const https = require(‘https’);
const port = process.env.PORT || 8443;
/* your app.get() blocks */
var httpsServer = https.createServer(credentials, app);
httpsServer.listen(port, function () {
console.log(“Listening on port ” + port + “!”);
});