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.

_application-786bec8dbeba5dccf3118668436791948e535eb587456944e94e0724bc417b14.js:76435 

Failed to register Service Worker: SecurityError: Failed to register a ServiceWorker for scope ('https://www.xxxxx.com/') with script ('https://www.xxxxxx.com/service-worker.js'): The script resource is behind a redirect, which is disallowed.

We host uploads on S3 and CND them via Cloudfront.

Anybody?

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 https://cdn-uploads.xxxxxxx.com/assets/_application-786bec8dbeba5dccf3118668436791948e535eb587456944e94e0724bc417b14.js (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