2

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

4

1 回答 1

5

req.protocol

app.get('/protocol', function (req, res) {
    res.send(req.protocol);
});

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

app.configure('production', function () {
    app.enable('trust proxy');
});
于 2012-09-13T23:01:07.013 回答