angular service worker with ngCspOnce - Degraded due to: Hash mismatch (cacheBustedFetchFromNetwork)

129 views Asked by At

Service Worker is broken since I started injecting nonce from nginx in index.html

as in

<app-root ngCspNonce="$requestId"></app-root>

following 1) from https://angular.io/guide/security#content-security-policy

The error says hash mismatch obviously due to injecting that nonce.

Wondering what are my options as I don;t wish to cache index.html since the nonce value must be unique every request ? Also option 2) from the Angular document for injecting CSP does not seem practical.

Wondering how do you deal with this ?

1

There are 1 answers

0
bhantol On

Answering my own question incase anyone stumbles across:-

Remove index.html from ngsw-config.json assetGroup that way it will not be cached hence not cache busted and the SW can function normally.