When multiple domains are configured with different base_href or spa_config values, the server generates a per-domain index.html with the appropriate base element and spa_config hash. ngsw.json, the Angular Service Worker manifest, is however served as-is from the build output, identical for all domains.
This causes several problems:
1. Hash mismatch for index.html
ngsw.json contains pre-computed hashes of all assets, including index.html. Since the server modifies index.html at startup (injecting base_href, rewriting spa_config.js references), the served content no longer matches the hash in the manifest. NGSW will detect a perpetual update or fail integrity validation.
2. spa_config.js referenced under its original name
The manifest references spa_config.js by its build-time filename, but the server returns 404 for /spa_config.js and only serves it at /spa_config.{hash}.js. NGSW will fail to prefetch this asset.
3. Same manifest for different domains
When two domains serve different index.html content, they each need an ngsw.json with matching hashes. Currently there is no mechanism for this.
Possible solution
Process ngsw.json at startup similarly to index.html: for each configured server, rewrite the asset hashes and URLs to reflect the per-domain modifications, and route /ngsw.json requests to the correct version based on server_name.
When multiple domains are configured with different
base_hreforspa_configvalues, the server generates a per-domainindex.htmlwith the appropriate base element and spa_config hash.ngsw.json, the Angular Service Worker manifest, is however served as-is from the build output, identical for all domains.This causes several problems:
1. Hash mismatch for
index.htmlngsw.jsoncontains pre-computed hashes of all assets, includingindex.html. Since the server modifiesindex.htmlat startup (injectingbase_href, rewritingspa_config.jsreferences), the served content no longer matches the hash in the manifest. NGSW will detect a perpetual update or fail integrity validation.2.
spa_config.jsreferenced under its original nameThe manifest references
spa_config.jsby its build-time filename, but the server returns 404 for/spa_config.jsand only serves it at/spa_config.{hash}.js. NGSW will fail to prefetch this asset.3. Same manifest for different domains
When two domains serve different
index.htmlcontent, they each need anngsw.jsonwith matching hashes. Currently there is no mechanism for this.Possible solution
Process
ngsw.jsonat startup similarly toindex.html: for each configured server, rewrite the asset hashes and URLs to reflect the per-domain modifications, and route/ngsw.jsonrequests to the correct version based onserver_name.