Appearance
Express request.protocol
TIP
包含请求协议字符串:http 或(对于 TLS 请求)https。
Express
req.protocol
当 trust proxy 设置 不计算为 false 时,此属性将使用 X-Forwarded-Proto标头字段的值(如果存在)。此标头可以由客户端或代理设置。
Express
console.dir(req.protocol)
// => "http"
req.secure
TIP
如果建立了 TLS 连接,则为 true 的布尔属性。
如果建立了 TLS 连接,则为 true 的布尔属性。相当于以下内容:
Express
req.protocol === 'https'