Skip to content

Commit 3573ac6

Browse files
alan-agius4clydin
authored andcommitted
fix(@angular/build): serve HTML files directly
Ensure direct requests to HTML files result in them being served. Closes #28063 (cherry picked from commit 11a140b)
1 parent 5b9378a commit 3573ac6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/angular/build/src/tools/vite/middlewares/index-html-middleware.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9+
import { extname } from 'node:path';
910
import type { Connect, ViteDevServer } from 'vite';
1011
import {
1112
AngularMemoryOutputFiles,
@@ -28,13 +29,14 @@ export function createAngularIndexHtmlMiddleware(
2829
// Parse the incoming request.
2930
// The base of the URL is unused but required to parse the URL.
3031
const pathname = pathnameWithoutBasePath(req.url, server.config.base);
31-
if (pathname !== '/' && pathname !== '/index.html') {
32+
const extension = extname(pathname);
33+
if (extension !== '.html') {
3234
next();
3335

3436
return;
3537
}
3638

37-
const rawHtml = outputFiles.get('/index.html')?.contents;
39+
const rawHtml = outputFiles.get(pathname)?.contents;
3840
if (!rawHtml) {
3941
next();
4042

0 commit comments

Comments
 (0)