From 950a44521fdfb82000f6564ccc4c87d4a2b94680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kubiak?= Date: Thu, 21 Mar 2024 21:58:09 +0100 Subject: [PATCH] fix(@schematics/angular): rename SSR port env variable Rename the SSR port env variable to SSR_PORT. It could help to resolve this firebase issue: https://github.com/firebase/firebase-tools/issues/6651#issuecomment-1881647322, cause PORT is reserved environment variable: https://firebase.google.com/docs/functions/config-env?gen=2nd#reserved-names. --- .../build_angular/src/builders/ssr-dev-server/index.ts | 2 +- .../src/builders/ssr-dev-server/specs/proxy_spec.ts | 2 +- .../build_angular/src/builders/ssr-dev-server/specs/ssl_spec.ts | 2 +- .../src/builders/ssr-dev-server/specs/works_spec.ts | 2 +- .../angular/migrations/update-17/replace-nguniversal-engines.ts | 2 +- .../migrations/update-17/replace-nguniversal-engines_spec.ts | 2 +- .../angular/ssr/files/application-builder/server.ts.template | 2 +- .../angular/ssr/files/server-builder/server.ts.template | 2 +- tests/legacy-cli/e2e/assets/18-ssr-project-webpack/server.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/index.ts b/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/index.ts index 847d4348bb5c..e5b43cf0836d 100644 --- a/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/index.ts +++ b/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/index.ts @@ -220,7 +220,7 @@ function startNodeServer( ): Observable { const outputPath = serverOutput.outputPath as string; const path = join(outputPath, 'main.js'); - const env = { ...process.env, PORT: '' + port }; + const env = { ...process.env, SSR_PORT: '' + port, PORT: '' + port }; const args = ['--enable-source-maps', `"${path}"`]; if (inspectMode) { diff --git a/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/proxy_spec.ts b/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/proxy_spec.ts index 61db7fa33509..e88c4af077c4 100644 --- a/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/proxy_spec.ts +++ b/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/proxy_spec.ts @@ -58,7 +58,7 @@ describe('Serve SSR Builder', () => { return server; } - app().listen(process.env['PORT']); + app().listen(process.env['SSR_PORT']); export * from './app/app.module.server'; `, diff --git a/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/ssl_spec.ts b/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/ssl_spec.ts index 60130092946f..6a831f7669f2 100644 --- a/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/ssl_spec.ts +++ b/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/ssl_spec.ts @@ -58,7 +58,7 @@ describe('Serve SSR Builder', () => { return server; } - app().listen(process.env['PORT']); + app().listen(process.env['SSR_PORT']); export * from './app/app.module.server'; `, diff --git a/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/works_spec.ts b/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/works_spec.ts index ab08119dd7b7..359ba271ee55 100644 --- a/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/works_spec.ts +++ b/packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs/works_spec.ts @@ -57,7 +57,7 @@ describe('Serve SSR Builder', () => { return server; } - app().listen(process.env['PORT']); + app().listen(process.env['SSR_PORT']); export * from './app/app.module.server'; `, diff --git a/packages/schematics/angular/migrations/update-17/replace-nguniversal-engines.ts b/packages/schematics/angular/migrations/update-17/replace-nguniversal-engines.ts index 97bbb794995e..88605df3e1bc 100644 --- a/packages/schematics/angular/migrations/update-17/replace-nguniversal-engines.ts +++ b/packages/schematics/angular/migrations/update-17/replace-nguniversal-engines.ts @@ -199,7 +199,7 @@ export function app(): express.Express { } function run(): void { - const port = process.env['PORT'] || 4000; + const port = process.env['SSR_PORT'] || 4000; // Start up the Node server const server = app(); diff --git a/packages/schematics/angular/migrations/update-17/replace-nguniversal-engines_spec.ts b/packages/schematics/angular/migrations/update-17/replace-nguniversal-engines_spec.ts index 4a07f6fe5426..eb0dada1183a 100644 --- a/packages/schematics/angular/migrations/update-17/replace-nguniversal-engines_spec.ts +++ b/packages/schematics/angular/migrations/update-17/replace-nguniversal-engines_spec.ts @@ -128,7 +128,7 @@ export function app(): express.Express { } function run() { - const port = process.env.PORT || 4000; + const port = process.env.SSR_PORT || 4000; // Start up the Node server const server = app(); diff --git a/packages/schematics/angular/ssr/files/application-builder/server.ts.template b/packages/schematics/angular/ssr/files/application-builder/server.ts.template index 7bf10181c7d1..becf161c4915 100644 --- a/packages/schematics/angular/ssr/files/application-builder/server.ts.template +++ b/packages/schematics/angular/ssr/files/application-builder/server.ts.template @@ -44,7 +44,7 @@ export function app(): express.Express { } function run(): void { - const port = process.env['PORT'] || 4000; + const port = process.env['SSR_PORT'] || 4000; // Start up the Node server const server = app(); diff --git a/packages/schematics/angular/ssr/files/server-builder/server.ts.template b/packages/schematics/angular/ssr/files/server-builder/server.ts.template index de1bf66f9726..5660620c6b6b 100644 --- a/packages/schematics/angular/ssr/files/server-builder/server.ts.template +++ b/packages/schematics/angular/ssr/files/server-builder/server.ts.template @@ -47,7 +47,7 @@ export function app(): express.Express { } function run(): void { - const port = process.env['PORT'] || 4000; + const port = process.env['SSR_PORT'] || 4000; // Start up the Node server const server = app(); diff --git a/tests/legacy-cli/e2e/assets/18-ssr-project-webpack/server.ts b/tests/legacy-cli/e2e/assets/18-ssr-project-webpack/server.ts index 129a75442957..9e59a0211eed 100644 --- a/tests/legacy-cli/e2e/assets/18-ssr-project-webpack/server.ts +++ b/tests/legacy-cli/e2e/assets/18-ssr-project-webpack/server.ts @@ -47,7 +47,7 @@ export function app(): express.Express { } function run(): void { - const port = process.env['PORT'] || 4000; + const port = process.env['SSR_PORT'] || 4000; // Start up the Node server const server = app();