fix(@angular/build): suppress asset missing warning for /index.html requests

Prevent incorrect warning display when the Service Worker requests `/index.html`.
This commit is contained in:
Alan Agius 2025-02-14 13:14:24 +00:00
parent 87b310a13f
commit f92787947f

View File

@ -28,7 +28,10 @@ export function angularHtmlFallbackMiddleware(
if (req.url) {
const mimeType = lookupMimeTypeFromRequest(req.url);
if (mimeType === 'text/html' || mimeType === 'application/xhtml+xml') {
if (
(mimeType === 'text/html' || mimeType === 'application/xhtml+xml') &&
!/^\/index\.(?:csr\.)?html/.test(req.url)
) {
// eslint-disable-next-line no-console
console.warn(
`Request for HTML file "${req.url}" was received but no asset found. Asset may be missing from build.`,