diff --git a/modules/testing/builder/projects/hello-world-app/angular.json b/modules/testing/builder/projects/hello-world-app/angular.json index 95607701be8f..536fe863f6da 100644 --- a/modules/testing/builder/projects/hello-world-app/angular.json +++ b/modules/testing/builder/projects/hello-world-app/angular.json @@ -103,7 +103,8 @@ "builder": "@angular-devkit/build-angular:dev-server", "options": { "buildTarget": "app:build", - "watch": false + "watch": false, + "host": "127.0.0.1" }, "configurations": { "production": { diff --git a/packages/angular/build/src/builders/dev-server/tests/setup.ts b/packages/angular/build/src/builders/dev-server/tests/setup.ts index 2c5906e9644d..0385e6834fd1 100644 --- a/packages/angular/build/src/builders/dev-server/tests/setup.ts +++ b/packages/angular/build/src/builders/dev-server/tests/setup.ts @@ -62,6 +62,10 @@ export const BASE_OPTIONS = Object.freeze({ buildTarget: 'test:build', port: 0, + // Force an IPv4 address as with RBE there are currently resolution issues with IPv6 addresses. + // http://localhost is resolved to IPv6 address with vite and webpack but to IPv4 with node fetch. + host: '127.0.0.1', + // Watch is not supported for testing in vite as currently there is no teardown logic to stop the watchers. watch: false, }); diff --git a/packages/angular_devkit/build_angular/src/builders/dev-server/specs/ssl_spec.ts b/packages/angular_devkit/build_angular/src/builders/dev-server/specs/ssl_spec.ts index 60ed65793c7f..51dba9d0a4d8 100644 --- a/packages/angular_devkit/build_angular/src/builders/dev-server/specs/ssl_spec.ts +++ b/packages/angular_devkit/build_angular/src/builders/dev-server/specs/ssl_spec.ts @@ -33,7 +33,7 @@ describe('Dev Server Builder ssl', () => { runs.push(run); const output = (await run.result) as DevServerBuilderOutput; expect(output.success).toBe(true); - expect(output.baseUrl).toMatch(/^https:\/\/localhost:\d+\//); + expect(output.baseUrl).toMatch(/^https:\/\/127\.0\.0\.1:\d+\//); const response = await fetch(output.baseUrl, { dispatcher: new Agent({ @@ -112,7 +112,7 @@ describe('Dev Server Builder ssl', () => { runs.push(run); const output = (await run.result) as DevServerBuilderOutput; expect(output.success).toBe(true); - expect(output.baseUrl).toMatch(/^https:\/\/localhost:\d+\//); + expect(output.baseUrl).toMatch(/^https:\/\/127\.0\.0\.1:\d+\//); const response = await fetch(output.baseUrl, { dispatcher: new Agent({ diff --git a/packages/angular_devkit/build_angular/src/builders/dev-server/tests/setup.ts b/packages/angular_devkit/build_angular/src/builders/dev-server/tests/setup.ts index f92d3b713c9f..7b8d3851544e 100644 --- a/packages/angular_devkit/build_angular/src/builders/dev-server/tests/setup.ts +++ b/packages/angular_devkit/build_angular/src/builders/dev-server/tests/setup.ts @@ -63,6 +63,10 @@ export const BASE_OPTIONS = Object.freeze({ buildTarget: 'test:build', port: 0, + // Force an IPv4 address as with RBE there are currently resolution issues with IPv6 addresses. + // http://localhost is resolved to IPv6 address with vite and webpack but to IPv4 with node fetch. + host: '127.0.0.1', + // Watch is not supported for testing in vite as currently there is no teardown logic to stop the watchers. watch: false, }); diff --git a/packages/angular_devkit/build_webpack/test/basic-app/webpack.config.cjs b/packages/angular_devkit/build_webpack/test/basic-app/webpack.config.cjs index b1f988ab2071..63a5a947e7ea 100644 --- a/packages/angular_devkit/build_webpack/test/basic-app/webpack.config.cjs +++ b/packages/angular_devkit/build_webpack/test/basic-app/webpack.config.cjs @@ -3,6 +3,11 @@ const path = require('path'); module.exports = { mode: 'development', entry: path.resolve(__dirname, './src/main.js'), + devServer: { + // Force an IPv4 address as with RBE there are currently resolution issues with IPv6 addresses. + // http://localhost is resolved to IPv6 address with vite and webpack but to IPv4 with node fetch. + host: '127.0.0.1', + }, module: { rules: [ // rxjs 6 requires directory imports which are not support in ES modules. diff --git a/packages/angular_devkit/build_webpack/test/basic-app/webpack.config.mjs b/packages/angular_devkit/build_webpack/test/basic-app/webpack.config.mjs index 289fff7bdb69..cd76b55970d3 100644 --- a/packages/angular_devkit/build_webpack/test/basic-app/webpack.config.mjs +++ b/packages/angular_devkit/build_webpack/test/basic-app/webpack.config.mjs @@ -4,6 +4,11 @@ import { fileURLToPath } from 'url'; export default { mode: 'development', entry: resolve(fileURLToPath(import.meta.url), '../src/main.js'), + devServer: { + // Force an IPv4 address as with RBE there are currently resolution issues with IPv6 addresses. + // http://localhost is resolved to IPv6 address with vite and webpack but to IPv4 with node fetch. + host: '127.0.0.1', + }, module: { rules: [ // rxjs 6 requires directory imports which are not support in ES modules.