diff --git a/packages/angular/build/src/tools/vite/middlewares/index-html-middleware.ts b/packages/angular/build/src/tools/vite/middlewares/index-html-middleware.ts index 7b9d275109fe..0dab0136c798 100644 --- a/packages/angular/build/src/tools/vite/middlewares/index-html-middleware.ts +++ b/packages/angular/build/src/tools/vite/middlewares/index-html-middleware.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.dev/license */ +import { extname } from 'node:path'; import type { Connect, ViteDevServer } from 'vite'; import { AngularMemoryOutputFiles, @@ -28,13 +29,14 @@ export function createAngularIndexHtmlMiddleware( // Parse the incoming request. // The base of the URL is unused but required to parse the URL. const pathname = pathnameWithoutBasePath(req.url, server.config.base); - if (pathname !== '/' && pathname !== '/index.html') { + const extension = extname(pathname); + if (extension !== '.html') { next(); return; } - const rawHtml = outputFiles.get('/index.html')?.contents; + const rawHtml = outputFiles.get(pathname)?.contents; if (!rawHtml) { next();