Skip to content

Commit f9a311a

Browse files
hanslKeen Yee Liau
authored and
Keen Yee Liau
committed
fix(@angular-devkit/build-angular): prints a warning on --host on serve
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
1 parent a0ac4b0 commit f9a311a

File tree

1 file changed

+14
-0
lines changed
  • packages/angular_devkit/build_angular/src/dev-server

1 file changed

+14
-0
lines changed

packages/angular_devkit/build_angular/src/dev-server/index.ts

+14
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,20 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
184184
browserOptions: NormalizedBrowserBuilderSchema,
185185
) {
186186
const systemRoot = getSystemPath(root);
187+
if (options.host) {
188+
// Check that the host is either localhost or prints out a message.
189+
if (!/^127\.\d+\.\d+\.\d+/g.test(options.host) && options.host !== 'localhost') {
190+
this.context.logger.warn(tags.stripIndent`
191+
WARNING: This is a simple server for use in testing or debugging Angular applications
192+
locally. It hasn't been reviewed for security issues.
193+
194+
Binding this server to an open connection can result in compromising your application or
195+
computer. Using a different host than the one passed to the "--host" flag might result in
196+
websocket connection issues. You might need to use "--disableHostCheck" if that's the
197+
case.
198+
`);
199+
}
200+
}
187201
if (options.disableHostCheck) {
188202
this.context.logger.warn(tags.oneLine`
189203
WARNING: Running a server with --disable-host-check is a security risk.

0 commit comments

Comments
 (0)