Skip to content
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

http: show real hostname being used when starting the server #57

Open
alexandercerutti opened this issue Jan 5, 2025 · 3 comments
Open

Comments

@alexandercerutti
Copy link
Contributor

alexandercerutti commented Jan 5, 2025

Is your feature request related to a problem? Please describe.

When starting the webserver, intent shows:

Listening on: http://localhost:5001/

However, the default behavior is listening on 0.0.0.0 when app.hostname is not defined, not on localhost / 127.0.0.1.

This behavior is not documented in the website (or I couldn't find it). It seems to be described only as a Typescript typing, without a comment.

So the current behavior is a bit misleading IMHO.

hostname seems to get used only for selecting server address and to print the URL.

const hostname = config.get('app.hostname');
await server.listen(port, hostname || '0.0.0.0');

Describe the solution you'd like

I'd like for the CLI to print the real address being used, so either app.hostname or "localhost" / "127.0.0.1".

The simplest way would be to hostname == undefined to fallback to 127.0.0.1 and not on 0.0.0.0 (0.0.0.0 also is said to be a bad practice if not really needed).

By doing this way, this piece of code already existing would work perfectly and, explicity specifying hostname to be 0.0.0.0, would make it work.

const url = new URL(
['127.0.0.1', 'localhost', undefined].includes(hostname)
? 'http://localhost'
: `http://${hostname}`,

However, I can understand this could be a breaking change, so it depends on how it is the will to proceed.

I'm also willing to open a PR and change the documentation.

Let me know.

Describe alternatives you've considered

Additional context

Copy link

linear bot commented Jan 5, 2025

@alexandercerutti alexandercerutti changed the title Cli: show real hostname being used Hhttp: show real hostname being used when starting the server Jan 5, 2025
@alexandercerutti alexandercerutti changed the title Hhttp: show real hostname being used when starting the server http: show real hostname being used when starting the server Jan 5, 2025
@vinayak25
Copy link
Member

@alexandercerutti thanks for reporting this issue, the reason I did it so as to avoid running into unknown deployment issues. Probably we can remove the default behaviour of listening to 0.0.0.0 and add a deployment documentation.

I will fix it and raise a PR, you can review it!

@alexandercerutti
Copy link
Contributor Author

Okay, feel free to tag me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants