How to know if a request is http or https in node.js

前端 未结 9 1233
别跟我提以往
别跟我提以往 2020-12-08 04:11

I am using nodejs and expressjs. I wonder if there is something like request.headers.protocol in the clientRequest object. I would like to build the baseUrl for

9条回答
  •  再見小時候
    2020-12-08 04:40

    If you are using Proxy Server such as Nginx you should set proxy_set_header X-Forwarded-Proto https; in its config file, so if you are using TSL express could recognize https as req.headers['x-forwarded-proto'] value or true for req.secure

提交回复
热议问题