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

Offline plugin fetch error #8158

Merged
merged 3 commits into from
Sep 14, 2018
Merged

Offline plugin fetch error #8158

merged 3 commits into from
Sep 14, 2018

Conversation

m-allanson
Copy link
Contributor

@m-allanson m-allanson commented Sep 14, 2018

Use no-cors mode when fetching external resources

This 'fixes' #8145, although I don't really understand what was causing that issue. So maybe this will need some extra testing.

for (const resource of resources) {
fetch(resource)
a.href = resource
Copy link
Contributor

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

Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor

@pieh pieh left a comment

Choose a reason for hiding this comment

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

🌮

@pieh pieh merged commit 5b1e3f4 into master Sep 14, 2018
@pieh pieh deleted the offline-external-cors branch September 14, 2018 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants