有没有办法在Connect/Express 3中获得协议

jwe*_*rre 2 connect node.js express

有没有办法在Express中获得协议(http | https)?

Jon*_*ski 5

req.protocol:

app.get('/protocol', function (req, res) {
    res.send(req.protocol);
});
Run Code Online (Sandbox Code Playgroud)

但是,您可能还需要为您的应用程序:enable trust proxy

app.configure('production', function () {
    app.enable('trust proxy');
});
Run Code Online (Sandbox Code Playgroud)