I have created a PWA with web2py but now I am facing a problem of
The site at (page address) has experienced a network protocol violation that cannot be repaired.
when trying to open other pages on the app after it has loaded & the service worker is registered.
This is my service worker code:
window.onload = () =>
{
'use strict';
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('https://www.example.com/sw.js');
}
}
Notification.requestPermission(result => {
if (result === 'granted') {
showNotification('Welcome to Sesoa™', 'Search for what you are looking for')
}
});
function showNotification(title, message) {
if ('Notification' in window) {
navigator.serviceWorker.ready.then(registration => {
registration.showNotification(title, {
body: message,
tag: 'sesoa',
icon:'/init/static/images/icon_192x192.png',
badge:'/init/static/images/icon_128x128.png',
vibrate: [200, 100, 200, 100, 200, 100]
});
});
}
}
What i figured is that when I remove the location of the service worker & leave the quotation marks blank like in the code portion below all app pages open up as expect, the whole app functions properly
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('');
}
But when I replace the address like below the problems begin
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('https://www.example.com/sw.js');
}
How can I resolve this problem?