Is there a way to get the protocol (http|https) in Express?
Asked
Active
Viewed 2,397 times
1 Answers
5
app.get('/protocol', function (req, res) {
res.send(req.protocol);
});
Though, you may also need to enable
trust proxy
for your application:
app.configure('production', function () {
app.enable('trust proxy');
});

Jonathan Lonowski
- 121,453
- 34
- 200
- 199
-
`app.enable('trust proxy'); app.get('trust proxy');// => true console.log(req.procotol) => undefined` That didn't seem to work – jwerre Sep 14 '12 at 05:44
-
@jwerre That likely because I had it as `procotol` rather than `protocol`. :) Sorry. – Jonathan Lonowski Sep 14 '12 at 21:23
-
Ha!! Copy & Paste stikes again – jwerre Sep 15 '12 at 21:04