KaiOS webapp for InfoFer scraper
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
const registerServiceWorker = async () => {
|
|
|
|
if ('serviceWorker' in navigator) {
|
|
|
|
try {
|
|
|
|
const registration = await navigator.serviceWorker.register(
|
|
|
|
'/sw.js',
|
|
|
|
{
|
|
|
|
scope: '/',
|
|
|
|
}
|
|
|
|
);
|
|
|
|
if (registration.installing) {
|
|
|
|
console.log('Service worker installing');
|
|
|
|
} else if (registration.waiting) {
|
|
|
|
console.log('Service worker installed');
|
|
|
|
} else if (registration.active) {
|
|
|
|
console.log('Service worker active');
|
|
|
|
}
|
|
|
|
} catch (error) {
|
Enable service worker for Safari
For future reference: the preflight request must return these headers:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization, Pragma, Cache-Control
Otherwise, Safari will refuse requests made inside a service worker
reporting a preflight check fail.
2 years ago
|
|
|
console.error('Registration failed', error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Enable service worker for Safari
For future reference: the preflight request must return these headers:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization, Pragma, Cache-Control
Otherwise, Safari will refuse requests made inside a service worker
reporting a preflight check fail.
2 years ago
|
|
|
registerServiceWorker();
|