Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use integrity when request is no-cors #3099

Merged
merged 4 commits into from Jul 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/workbox-precaching/src/PrecacheStrategy.ts
Expand Up @@ -133,7 +133,10 @@ class PrecacheStrategy extends Strategy {
!integrityInRequest || integrityInRequest === integrityInManifest;
response = await handler.fetch(
new Request(request, {
integrity: integrityInRequest || integrityInManifest,
integrity:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add

// See https://github.com/GoogleChrome/workbox/issues/3096

so that the context is not lost?

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