-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Offline plugin fetch error #8158
Conversation
for (const resource of resources) { | ||
fetch(resource) | ||
a.href = resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use const a = new URL(resource)
here - same effect but we don't need to create a hidden element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also might be better to rename this if it lo longer uses an <a>
tag
for (const resource of resources) { | ||
fetch(resource) | ||
a.href = resource | ||
const isExternal = (a.host && a.host !== window.location.host) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be .origin
rather than .host
since a URL is considered cross-origin if the port or protocol are different. Also, if we use new URL()
as above then it guarantees the variable a
has a .origin
property, so the check can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌮
Use
no-cors
mode when fetching external resourcesThis 'fixes' #8145, although I don't really understand what was causing that issue. So maybe this will need some extra testing.