Skip to content

Instantly share code, notes, and snippets.

@lmammino
Created June 22, 2021 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmammino/34373d61ff28ba34c9c26eb1edad5684 to your computer and use it in GitHub Desktop.
Save lmammino/34373d61ff28ba34c9c26eb1edad5684 to your computer and use it in GitHub Desktop.
Node.js debug server
const { createServer } = require('http');
createServer((req, res) => {
console.log('--------');
console.log(JSON.stringify(req.headers, null, 2));
req.pipe(process.stdout);
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify({ok:true}));
})
.listen(8000);
// Start with `node server.js`
// then send requests to localhost:8000 and look at the logs to inspect the incoming traffic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment