fastify-cli
fastify-cli copied to clipboard
Cannot set trustProxy with fastify-cli
Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.12.0
Plugin version
No response
Node.js version
18.12.1
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13.1
Description
I cannot set trustProxy to true when starting my fastify server with fastify-cli.
Steps to Reproduce
1. Use config.js
module.exports = {
trustProxy: true,
port: 3300
}
then run it with:
fastify start -l warn --config config.js dist/App.js
2. .env file
TRUST_PROXY=TRUE
TRUST_PROXY=true
and also
TRUST_PROXY=1
3. Pass env variable
TRUST_PROXY=true fastify start -l warn dist/App.js
And all other variations ( TRUE, 1, true )
None of them are setting trustProxy to true, I tested it. The only way it works is by creating the server manually:
const app = Fastify({
trustProxy: true,
logger: {
level: "info"
}
});
Expected Behavior
I expected at least one of them to work, the env file or config.js
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
Let me try it
hei @alexandrucancescu I resolve that in #654