Skip to content

Improve logging when IP address is not private #11958

Open
@fredrvaa

Description

@fredrvaa

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions