Skip to content

Commit

Permalink
Add Service-Worker header to checkValidServiceWorker (#6753)
Browse files Browse the repository at this point in the history
* Add header to checkValidServiceWorker (ts)

* Add header to checkValidServiceWorker
  • Loading branch information
darthmaim authored and iansu committed Oct 23, 2019
1 parent 5ea3b34 commit ea34c1d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ function registerValidSW(swUrl: string, config?: Config) {

function checkValidServiceWorker(swUrl: string, config?: Config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
fetch(swUrl, {
headers: { 'Service-Worker': 'script' }
})
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
Expand Down
4 changes: 3 additions & 1 deletion packages/react-scripts/template/src/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ function registerValidSW(swUrl, config) {

function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
fetch(swUrl, {
headers: { 'Service-Worker': 'script' }
})
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
Expand Down

0 comments on commit ea34c1d

Please sign in to comment.