Skip to content

Commit

Permalink
fix(@angular/build): serve HTML files directly
Browse files Browse the repository at this point in the history
Ensure direct requests to HTML files result in them being served.

Closes #28063

(cherry picked from commit 11a140b)
  • Loading branch information
alan-agius4 authored and clydin committed Jul 19, 2024
1 parent 5b9378a commit 3573ac6
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();

Expand Down

0 comments on commit 3573ac6

Please sign in to comment.