Я пытаюсь настроить тему WordPress в качестве прогрессивного веб-приложения.Когда я запускаю инструмент Chromes Audit (маяк?), Я получаю неинформативную ошибку, в которой я не знаю, в чем именно заключается проблема.Ошибка:
Сбои: Сервисный работник не успешно обслуживает манифест start_url.Невозможно получить стартовый URL через сервисного работника
Я жестко запрограммировал мой стартовый URL, который является действительным URL.Любые предложения о том, что проблема может быть?
https://mywebsite.com/wp-content/themes/mytheme/web.manifest
:
...
"scope": "/",
"start_url": "https://mywebsite.com",
"serviceworker": {
"src": "dist/assets/sw/service-worker.js",
"scope": "/aw/",
"update_via_cache": "none"
},
...
}
https://mywebsite.com/wp-content/themes/mytheme/dist/assets/sw/service-worker.js
:
...
// The fetch handler serves responses for same-origin resources from a cache.
// If no response is found, it populates the runtime cache with the response
// from the network before returning it to the page.
self.addEventListener('fetch', event => {
// Skip cross-origin requests, like those for Google Analytics.
if (event.request.url.startsWith(self.location.origin)) {
event.respondWith(
caches.match(event.request).then(cachedResponse => {
if (cachedResponse) {
return cachedResponse;
}
return caches.open(RUNTIME).then(cache => {
return fetch(event.request).then(response => {
// Put a copy of the response in the runtime cache.
return cache.put(event.request, response.clone()).then(() => {
return response;
});
});
});
})
);
}
});
Я регистрирую свое ПО с помощью следующего кода ивыводит, что успешно зарегистрировал ПО:
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register(Vue.prototype.$ASSETS_PATH + 'sw/service-worker.js')
.then(function(registration) {
console.log('Registration successful, scope is:', registration.scope);
})
.catch(function(error) {
console.log('Service worker registration failed, error:', error);
});
}