mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-06-19 17:53:49 +08:00
Add Service-Worker header to checkValidServiceWorker (#6753)
* Add header to checkValidServiceWorker (ts) * Add header to checkValidServiceWorker
This commit is contained in:
committed by
Ian Sutherland
parent
5ea3b345df
commit
ea34c1dae9
@@ -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');
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user