Skip to content

Commit

Permalink
Offline plugin fetch error (#8158)
Browse files Browse the repository at this point in the history
* Use 'no-cors' mode when fetching external resources

* Review feedback

* No log
  • Loading branch information
m-allanson authored and pieh committed Sep 14, 2018
1 parent 6592aaa commit 5b1e3f4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/gatsby-plugin-offline/src/gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ exports.onServiceWorkerInstalled = ({ getResourceURLsForPathname }) => {
.map(node => node.src || node.href || node.getAttribute(`data-href`))

for (const resource of resources) {
fetch(resource)
const url = new URL(resource, window.location.origin)
const isExternal = url.origin !== window.location.origin
fetch(
resource,
isExternal ? { mode: `no-cors` } : undefined
)
}

// Loop over all resources and fetch the page component and JSON
Expand Down

0 comments on commit 5b1e3f4

Please sign in to comment.