fastify-cli icon indicating copy to clipboard operation
fastify-cli copied to clipboard

Cannot set trustProxy with fastify-cli

Open alexandrucancescu opened this issue 1 year ago • 3 comments

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

alexandrucancescu avatar Apr 27 '23 21:04 alexandrucancescu

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

mcollina avatar May 03 '23 14:05 mcollina

Let me try it

yazaldefilimone avatar Aug 10 '23 17:08 yazaldefilimone

hei @alexandrucancescu I resolve that in #654

yazaldefilimone avatar Aug 10 '23 23:08 yazaldefilimone