Include scope fix for service worker as shown: https://stackoverflow.com/questions/46541071/progressive-web-app-does-not-work-offline-error
This commit is contained in:
@@ -14,14 +14,14 @@
|
||||
<script type="text/javascript">
|
||||
// Initialize the service worker
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', function () {
|
||||
navigator.serviceWorker.register('/serviceworker.js').then(function (registration) {
|
||||
// Registration was successful
|
||||
console.log('django-progressive-web-app: ServiceWorker registration successful with scope: ', registration.scope);
|
||||
}).catch(function (err) {
|
||||
// registration failed :(
|
||||
console.log('django-progressive-web-app: ServiceWorker registration failed: ', err);
|
||||
});
|
||||
navigator.serviceWorker.register('/serviceworker.js', {
|
||||
scope: '.' // <--- THIS BIT IS REQUIRED
|
||||
}).then(function (registration) {
|
||||
// Registration was successful
|
||||
console.log('django-progressive-web-app: ServiceWorker registration successful with scope: ', registration.scope);
|
||||
}, function (err) {
|
||||
// registration failed :(
|
||||
console.log('django-progressive-web-app: ServiceWorker registration failed: ', err);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user