From f18f204cc89b36f09c1c116bc8a37810785bdece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leosvel=20P=C3=A9rez=20Espinosa?= Date: Fri, 19 Jul 2024 17:10:03 +0200 Subject: [PATCH] fix(angular): generate correct server file when using webpack-based executors --- .../__snapshots__/setup-ssr.spec.ts.snap | 24 +++++++++++-------- .../server-builder/v17+/__serverFileName__ | 12 ++++++---- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/packages/angular/src/generators/setup-ssr/__snapshots__/setup-ssr.spec.ts.snap b/packages/angular/src/generators/setup-ssr/__snapshots__/setup-ssr.spec.ts.snap index 8170d0628afda..92fdc452d3d35 100644 --- a/packages/angular/src/generators/setup-ssr/__snapshots__/setup-ssr.spec.ts.snap +++ b/packages/angular/src/generators/setup-ssr/__snapshots__/setup-ssr.spec.ts.snap @@ -356,13 +356,15 @@ export function app(): express.Express { // Example Express Rest API endpoints // server.get('/api/**', (req, res) => { }); // Serve static files from /browser - server.get('**', express.static(distFolder, { - maxAge: '1y', - index: 'index.html' - })); + server.get( + '*.*', + express.static(distFolder, { + maxAge: '1y', + }) + ); // All regular routes use the Angular engine - server.get('**', (req, res, next) => { + server.get('*', (req, res, next) => { const { protocol, originalUrl, baseUrl, headers } = req; commonEngine @@ -457,13 +459,15 @@ export function app(): express.Express { // Example Express Rest API endpoints // server.get('/api/**', (req, res) => { }); // Serve static files from /browser - server.get('**', express.static(distFolder, { - maxAge: '1y', - index: 'index.html' - })); + server.get( + '*.*', + express.static(distFolder, { + maxAge: '1y', + }) + ); // All regular routes use the Angular engine - server.get('**', (req, res, next) => { + server.get('*', (req, res, next) => { const { protocol, originalUrl, baseUrl, headers } = req; commonEngine diff --git a/packages/angular/src/generators/setup-ssr/files/server/server-builder/v17+/__serverFileName__ b/packages/angular/src/generators/setup-ssr/files/server/server-builder/v17+/__serverFileName__ index 082dc313e699e..fc75b432497ae 100644 --- a/packages/angular/src/generators/setup-ssr/files/server/server-builder/v17+/__serverFileName__ +++ b/packages/angular/src/generators/setup-ssr/files/server/server-builder/v17+/__serverFileName__ @@ -23,13 +23,15 @@ export function app(): express.Express { // Example Express Rest API endpoints // server.get('/api/**', (req, res) => { }); // Serve static files from /browser - server.get('**', express.static(distFolder, { - maxAge: '1y', - index: 'index.html' - })); + server.get( + '*.*', + express.static(distFolder, { + maxAge: '1y', + }) + ); // All regular routes use the Angular engine - server.get('**', (req, res, next) => { + server.get('*', (req, res, next) => { const { protocol, originalUrl, baseUrl, headers } = req; commonEngine