Add Service-Worker header to checkValidServiceWorker (#6753)

* Add header to checkValidServiceWorker (ts)

* Add header to checkValidServiceWorker
This commit is contained in:
darthmaim
2019-10-23 23:20:24 +02:00
committed by Ian Sutherland
parent 5ea3b345df
commit ea34c1dae9
2 changed files with 6 additions and 2 deletions

View File

@@ -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');

View File

@@ -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');