Skip to content

Commit

Permalink
Do not use integrity when request is no-cors
Browse files Browse the repository at this point in the history
  • Loading branch information
tropicadri committed Jul 19, 2022
1 parent 4e80b58 commit aeb5f1c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/workbox-precaching/src/PrecacheStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ class PrecacheStrategy extends Strategy {
!integrityInRequest || integrityInRequest === integrityInManifest;
response = await handler.fetch(
new Request(request, {
integrity: integrityInRequest || integrityInManifest,
integrity:
request.mode !== 'no-cors'
? integrityInRequest || integrityInManifest
: undefined,
}),
);

Expand All @@ -142,7 +145,11 @@ class PrecacheStrategy extends Strategy {
// and there's either a) no integrity property in the incoming request
// or b) there is an integrity, and it matches the precache manifest.
// See https://github.com/GoogleChrome/workbox/issues/2858
if (integrityInManifest && noIntegrityConflict) {
if (
integrityInManifest &&
noIntegrityConflict &&
request.mode !== 'no-cors'
) {
this._useDefaultCacheabilityPluginIfNeeded();
const wasCached = await handler.cachePut(request, response.clone());
if (process.env.NODE_ENV !== 'production') {
Expand Down

0 comments on commit aeb5f1c

Please sign in to comment.