فشل تسجيل Service Worker: خطأ أمني بسبب إعادة توجيه

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)

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

إعجاب واحد (1)

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)

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

إعجاب واحد (1)

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)

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)

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)

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)

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

Looks resolved. Thank you!

إعجاب واحد (1)