Created
June 22, 2021 13:24
-
-
Save lmammino/34373d61ff28ba34c9c26eb1edad5684 to your computer and use it in GitHub Desktop.
Node.js debug server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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