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

Improve logging when IP address is not private #11958

Open
fredrvaa opened this issue Jan 19, 2022 · 0 comments
Open

Improve logging when IP address is not private #11958

fredrvaa opened this issue Jan 19, 2022 · 0 comments

Comments

@fredrvaa
Copy link

Is your proposal related to a problem?

When fetching the ip address here

lanUrlForConfig = address.ip();
if (lanUrlForConfig) {
// Check if the address is a private ip
// https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces
if (
/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(
lanUrlForConfig
)
) {
// Address is private, format it for later use
lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig);
} else {
// Address is not private, so we will discard it
lanUrlForConfig = undefined;
}
lanUrlForConfig is set to undefined if the ip address is not private. This results in the error Invalid options object. Dev Server has been initialized using an options object that does not match the API schema. - options.allowedHosts[0] should be a non-empty string. I was having a Hamachi server https://www.vpn.net/ open in the background, and it took a long time to figure out that the ip address fetched was the ip address of the hamachi server (starting with 25, i.e. not private).

Describe the solution you'd like

If the error should indeed happen in this case I would like the logging to be improved. Maybe tell the user that the ip is not private, and is what causes the error.

Describe alternatives you've considered

In the start when I encountered the error, I worked around it using the solution stated in https://stackoverflow.com/questions/70374005/invalid-options-object-dev-server-has-been-initialized-using-an-options-object/70491173#70491173 which indeed worked. This was just a bandaid solution however.

Additional context

This is related to #11762 and #11877

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

No branches or pull requests

1 participant