Failed to register Service Worker: Security Error because of redirect

Since the latest update we get the following JS errors re Service Worker in Chrome:

The script resource is behind a redirect, which is disallowed.


Failed to register Service Worker: SecurityError: Failed to register a ServiceWorker for scope ('') with script (''): The script resource is behind a redirect, which is disallowed.

We host uploads on S3 and CND them via Cloudfront.


1 Like

I’m not sure; I know @falco is making some service worker changes.

1 Like

Strange thing is I get

Could not load content for (HTTP error: status code 403, net::ERR_HTTP_RESPONSE_CODE_FAILURE)

when I look up the script in the debug console.

Seems, it is not there. Will try a rebuild the app now once again. Maybe a glitch?

1 Like

If you cURL the service worker URL do you get a 3xx instead of a 2xx response?

1 Like

200 for the service worker.js

but strangely a

403 for the script that loads it.

Will report back, once the app is rebuilt once again.

1 Like

So the _aplication is a Chrome DevTools mistake. It’s the pretty printed version of application, so it doesn’t really exists. That’s not the issue this topic is about…

So it’s not behind a redirect. Maybe your browser cached this a redirect on that URL? Can you check this specific request in DevTools Network tab?

1 Like

I have rebuilt the app now, but the error persists. Does not get all scripts get new urls on rebuild, thus should bust the cache?

Can you share the site URL?

1 Like

Error persist even with cache disabled in debug.

I’m getting a 302 redirect for service worker file, while it’s a simple 200 here on Meta. Can you try a rebuild?

1 Like

Have rebuilt the app now for a second time. Error gone.

Looks resolved. Thank you!

1 Like