-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FST_ERR_DEC_ALREADY_PRESENT error when set trustProxy
to true
#50
Comments
Thanks for the report! We can provide two properties at the same time, if the The second one can always be set, something like Would you like to submit a PR? |
Yes, I can do a PR. However, we could redefine the getter |
For example : const isTrustProxyOn = [
'ip',
'ips',
'hostname',
'protocol'
].every((key) => instance.hasRequestDecorator(key))
if (isTrustProxyOn) {
async function redefineIpDecorator (request) {
Object.defineProperty(request, 'ip', {
get () {
return ipDecorator.getter.apply(request)
}
})
}
instance.addHook('preHandler', redefineIpDecorator)
} else {
instance.decorateRequest('ip', ipDecorator)
} Where |
sgtm. i’d just recommend to not re define the property but rather just assign it. let’s also document this in the documentation |
Unfortunately, I can't assign a value as the setter is not implemented (TypeError). We could also propose a PR on fastify, but the simplest solution would be to redefine the property into I will do a PR in any cases. |
ah good callout, then that's fine 👍 |
Thanks for the fast answer and the release ❤️ 🚀 |
Thanks 👍. |
Describe the bug
If the
trustProxy
option is set to true, the following error occurs:FST_ERR_DEC_ALREADY_PRESENT
.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Should not return any errors.
Screenshots

The text was updated successfully, but these errors were encountered: