From 54da51ac27d704ad43c5dd4406c2c3626cac790d Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 22 Jan 2024 08:23:50 +0000 Subject: [PATCH] fix(@angular-devkit/build-angular): pre-transform error when using vite with SSR This commit fixes a regression which causes a pre-transform error when using vite with ssr. The `request.url` is now passed to the index transformer instead of `request.originalUrl`. This is because the `request.url` will have a value of the `index.html`. Closes #26897 --- .../build_angular/src/tools/vite/angular-memory-plugin.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts b/packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts index beeb71b6e8ac..b9039c2027dd 100644 --- a/packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts +++ b/packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts @@ -176,6 +176,7 @@ export function createAngularMemoryPlugin(options: AngularMemoryPluginOptions): ) { const url = req.originalUrl; if ( + !req.url || // Skip if path is not defined. !url || // Skip if path is like a file. @@ -194,7 +195,7 @@ export function createAngularMemoryPlugin(options: AngularMemoryPluginOptions): return; } - transformIndexHtmlAndAddHeaders(url, rawHtml, res, next, async (html) => { + transformIndexHtmlAndAddHeaders(req.url, rawHtml, res, next, async (html) => { const { content } = await renderPage({ document: html, route: new URL(req.originalUrl ?? '/', server.resolvedUrls?.local[0]).toString(),