req.protocol
This property contains the protocol. It is either http or
https.
index.js
const express = require('express') var cookieParser = require('cookie-parser') const app = express() app.use(cookieParser()); app.get('/', (req, res) => res.send(`Request protocol ${req.protocol}`)) const port = 3000 app.listen(port, () => console.log(`Application started listening on port ${port}!`));
Run index.js.
Open the url ‘http://localhost:3000/’ in browser.
You will below kind of message.
No comments:
Post a Comment