Service Worker

Hey Guys, does Infinity Free support service workers? I’m trying to make it a PWA.
If it does support SW, I’m getting this as an error:
The script resource is behind a redirect, which is disallowed.
What could be wrong with my index.html, or service-worker.js please?
They are both in the htdocs root folder.
Thanks.

A service worker runs completely within the browsers of your visitors, so there aren’t any special server needs to run it.

That said, we do run a security system which ensures that your website can only be opened in a web browser. This security system could interfere with service workers, but as long as the service workers also send the cookies for the domain, it should work fine. I don’t know enough about service workers to say for certain.

Before concluding that this security system is the issue, could you please double check what the redirect actually is? If it’s a redirect from HTTP to HTTPS or from the non-www domain to the www subdomain (or the other way around), you may be able to fix that and use service workers on your site.

3 Likes

Thanks for the speedy reply.
I have checked and it looks good. I’m using a freenom name and https, but I dont see anything out of place with that.

I read the knowledge base and a PWA should work since its a mobile browser not trying to run it through a native app. I want to add onesignal push notifications, but now I doubt that will work as well if I cant get this sorted.

I wasn’t really referring to the presence of an SSL certificate or whatever, but more about any redirects present on your website.

But you also use Cloudflare, which can be a cause of redirect issues.

But regarding the original error message:

Can you see which script resource is the issue here?

service-worker.js, I’m assuming thats what they are speaking of.

I dont have any redirects on the website.

Can you please check this? I have some assumptions too, but I think we need data, not assumptions, to fix this.

Sorry for the late reply.
(‘https://www.876sinc.gq/service-worker.js’): The script resource is behind a redirect, which is disallowed. That is the script.
Below is the code.

const cacheName = `876SINC`;
self.addEventListener('install', e => {
  e.waitUntil(
    caches.open(cacheName).then(cache => {
      return cache.addAll([
        `/`,
        `index.html`,
        `/sinc/login.php`,
        `/opsplate/modal.css`,
        `/opsplate/form.css`,
        `/opsplate/style.css`,
        `/opsplate/menu.html`,
        `offline.html`
      ])
          .then(() => self.skipWaiting());
    })
  );
});

self.addEventListener('activate', event => {
  event.waitUntil(self.clients.claim());
});

self.addEventListener('fetch', event => {
  event.respondWith(
    caches.open(cacheName)
      .then(cache => cache.match(event.request, {ignoreSearch: true}))
      .then(response => {
      return response || fetch(event.request);
    })
  );
});

Very strange, I don’t see any redirects on that URL at all. And since you’re using Cloudflare, the Javascript/cookie challenge thing should also not interfere with your service worker script.

3 Likes

Yup, But, I’m still at a lost as to what the issue might be.
I’m gonna remove the manifest and the service worker, clear the cache and redo the entire process and see if the problem persists. I will update accordingly.
If you have any suggestions, I’d truly appreciate it. Thank you.

Admin, I went in, erased everything, cleared the cache, ran the site, then went back in re-added the manifest link and service worker script and it is working now. Thanks much for the assistance.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.