Ensure font stylesheets are requested in CORS mode in both AMP and non-AMP documents #1486
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The AMP plugin is currently using the post-processor to add
crossorigin=anonymous
to font stylesheet links. This is not being done, however, in the non-AMP responses. This is a problem because when a service worker is caching the font stylesheet responses with CORS but then tries to serve it in response to a stylesheet being requested without CORS, then the fetch fails entirely with:So we need to make sure that such font URLs always get served with CORS (
crossorigin="anonymous"
) when in AMP and not-AMP alike to prevent this problem from happening.Another benefit of CORS is that it ensures that a service worker caching the external stylesheet will not inflate the storage quota. See:
This PR is cherry-picking 02fd0a7 from #1261. We'll not ship the PWA plugin integration for 1.0, but this fix needs to be deployed first.