Request.secure() doesn't work behind a proxy that forwards as http.
Something like this would work maybe?
class Request {
function secure() {
return nodeReq.secure(this.request) || this.header('X-Forwarded-Proto')=='https'
}
}
Yeah it will be better to implement this in nodeReq. I will do that
Looking the code and it seems that it does takes the X-Forwarded-Proto header for the proxy server into consideration when fetching the protocol.
https://github.com/poppinss/node-req/blob/develop/src/Request/index.js#L291
Can u please make sure that value of trustProxy is set to true inside config/app.js
This was not my issue, so I don't have an immediate test case. Shall we add something to the docs and then close this?
I have added a recipe that shows the minimal/ideal config of nginx and also stated that the of trustProxy should be true. I believe that will be enough to educate the end-user.
I personally tested all of the following methods behind nginx and they all work fine.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Yeah it will be better to implement this in nodeReq. I will do that