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

workbox-strategies / getCacheKeyForURL should account for CORS #3024

Closed
allanlei opened this issue Feb 3, 2022 · 2 comments
Closed

workbox-strategies / getCacheKeyForURL should account for CORS #3024

allanlei opened this issue Feb 3, 2022 · 2 comments
Labels
Needs More Info Waiting on additional information from the community.

Comments

@allanlei
Copy link

allanlei commented Feb 3, 2022

Library Affected:
workbox-strategies

Browser & Platform:

  • Chrome Linux Version 97.0.4692.99 (Official Build) (64-bit)

Issue or Feature Request Description:
Using StaleWhileRevalidate with URLs (ie api.example.com) that

  • Have CORS with non-wildcard domains (ie access-control-allow-origin: google.com, etc)
  • Publicly cachable (ie Cache-Control: public, max-age: ...)
  • Used on multiple Origin domains (app.example.com and example.com)
    will produce CORS errors on the second visited domain with a CORS error saying the resource is for the first domain.

Since getCacheKeyForURL only accounts for location.href and not Origin, then the response of the first domain is given as a cached response to the second.

@jeffposnick
Copy link
Contributor

Hello @allanlei—the code that you linked to, getCacheKeyForURL(), is part of the workbox-precaching library. It's not run as part of StaleWhileRevalidate in workbox-strategies.

Can you provide a live example that demonstrates the problem, or point to more specific code?

@jeffposnick jeffposnick added the Needs More Info Waiting on additional information from the community. label Feb 3, 2022
@allanlei
Copy link
Author

allanlei commented Feb 7, 2022

@jeffposnick I'll have to close this issue for now as it turns out the issue is somewhere else.

For reference, the issue I was having was related to 304 responses not having CORS (see httpwg/http-core#165)

@allanlei allanlei closed this as completed Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info Waiting on additional information from the community.
Projects
None yet
Development

No branches or pull requests

2 participants