[cli] Replace "0.0.0.0" with "localhost" in vc dev (#8547)

Instead of replacing "127.0.0.1" in `vc dev`, replace "0.0.0.0" when rendering the URL to access the `vc dev` server.

The thought here is that the IPv6 form is replacing the catch-all host name (`::`), but the IPv4 version is only replacing the explicit "127.0.0.1" version, so there's an inconsistency.

Considering the catch-all host names are not usually intended to be routable anyways, we will fix the inconsistency by only replacing the catch-all versions instead of localhost.

Also, since Node.js will default to binding to the catch-all address when not explicitly specifying a host, this replacement will only happen in that case. If the user is explicitly specifing a host to bind to (i.e. `vc dev -l 127.0.0.1:8080` or `vc dev -l tcp://[::1]:8080`) then it makes more sense to print explicitly what the user specified.
This commit is contained in:
Nathan Rajlich
2022-09-13 11:38:42 -07:00
committed by GitHub
parent 0bafea6d51
commit f3f3d7df5b
4 changed files with 24 additions and 9 deletions

View File

@@ -103,6 +103,7 @@ import {
} from '../is-error';
import isURL from './is-url';
import { pickOverrides } from '../projects/project-settings';
import { replaceLocalhost } from './parse-listen';
const frontendRuntimeSet = new Set(
frameworkList.map(f => f.useRuntime?.use || '@vercel/static-build')
@@ -930,9 +931,7 @@ export default class DevServer {
}
}
this._address = new URL(
address.replace('[::]', 'localhost').replace('127.0.0.1', 'localhost')
);
this._address = new URL(replaceLocalhost(address));
const vercelConfig = await this.getVercelConfig();
const devCommandPromise = this.runDevCommand();