fix: use request.protocol to check for HTTPS#282
fix: use request.protocol to check for HTTPS#282gurgunday merged 1 commit intofastify:masterfrom mohd-akram:fix-protocol-check
Conversation
gurgunday
left a comment
There was a problem hiding this comment.
Is there a problem with trusting the header here? We'd at worst be sending secure=true, and if that's not really the case, the browser would ignore it
But I agree with you in principle that proxies should not be trusted when trustProxy is disabled
@fastify/plugins is this breaking?
|
I don't think so. |
|
I don't think always sent Even if the next hop is not a trust proxy, sending |
|
That was what I thought... but the reason I approved anyway is trustProxy wasn't respected at the end of the day... I could accept the following: if (opts.secure === 'auto') {
if (reply.request.protocol === 'https' || (fastify.trustProxy === true && request.headers['x-forwarded-proto'] === 'https')) {
opts.secure = true
} else {
opts.sameSite = 'lax'
}
}However, should be noted that |
This is the same as |
The header shouldn't be read unless
trustProxyis true.Checklist
npm run testandnpm run benchmarkand the Code of conduct