nodejs express port code example
Example 1: app.listen express
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
Example 2: express get port from request
const proxyHost = req.headers["x-forwarded-host"];
const host ? proxyHost : req.headers.host;