HTTP and HTTPS Modules in Detail — a practical guide to Node.js https module with clear examples you can reuse in real projects.
HTTP and HTTPS Modules in Detail — 26/55 in the Node.js series. Full playlist companion: Node.js complete course on YouTube. Prefer one article? Read the complete Node.js tutorial.
Short description
`https` works like `http` but requires TLS certificates. In production, TLS is often terminated by a reverse proxy (Nginx), while Node still serves HTTP locally.
Read request URL and method
const http = require('http');
const url = require('url');
http.createServer((req, res) => {
const parsed = url.parse(req.url, true);
console.log(req.method, parsed.pathname, parsed.query);
res.end('ok');
}).listen(3000);