fix(service-worker): use relative path for ngsw.json

Not every application is served from the domain root. The Service
Worker made a bad assumption that it would be, and so requested
/ngsw.json from the domain root.

This change corrects this assumption, and requests ngsw.json without
the leading slash. This causes the request to be interpreted
relative to the SW origin, which will be the application root.
This commit is contained in:
Alex Rickabaugh
2017-11-30 09:51:09 -08:00
parent 3fbcde9048
commit f582620d5b
3 changed files with 8 additions and 8 deletions

View File

@ -580,8 +580,8 @@ export class Driver implements Debuggable, UpdateSource {
* Retrieve a copy of the latest manifest from the server.
*/
private async fetchLatestManifest(): Promise<Manifest> {
const res = await this.safeFetch(
this.adapter.newRequest('/ngsw.json?ngsw-cache-bust=' + Math.random()));
const res =
await this.safeFetch(this.adapter.newRequest('ngsw.json?ngsw-cache-bust=' + Math.random()));
if (!res.ok) {
if (res.status === 404) {
await this.deleteAllCaches();