Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): prints a warning on --host on serve
Browse files Browse the repository at this point in the history
The warning points to a solution for the WDS disconnect issue. Using --disable-host-check
will additionally warn the user that this might be insecure.

Fixes #11060
  • Loading branch information
hansl authored and kyliau committed Jan 14, 2019
1 parent aab904e commit 4de0ba9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/angular_devkit/build_angular/src/dev-server/index.ts
Expand Up @@ -184,6 +184,20 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
browserOptions: NormalizedBrowserBuilderSchema,
) {
const systemRoot = getSystemPath(root);
if (options.host) {
// Check that the host is either localhost or prints out a message.
if (!/^127\.\d+\.\d+\.\d+/g.test(options.host) && options.host !== 'localhost') {
this.context.logger.warn(tags.stripIndent`
WARNING: This is a simple server for use in testing or debugging Angular applications
locally. It hasn't been reviewed for security issues.
Binding this server to an open connection can result in compromising your application or
computer. Using a different host than the one passed to the "--host" flag might result in
websocket connection issues. You might need to use "--disableHostCheck" if that's the
case.
`);
}
}
if (options.disableHostCheck) {
this.context.logger.warn(tags.oneLine`
WARNING: Running a server with --disable-host-check is a security risk.
Expand Down

0 comments on commit 4de0ba9

Please sign in to comment.