ServiceWorker script evaluation failed due to HTTP (not HTTPS)

I have some problem with some JS. In the dev-tools I see (after installing some official plugins):


I’m not sure where to start debugging this.
Searching for the message “Failed to register Service Worker: TypeError: Failed to register a ServiceWorker: ServiceWorker script evaluation failed” on Google suggests there is a problem with the JS but I’m don’t know where it is coming from.
Have anybody got this issue before?

Did you enable force_https in the site settings?

I’m not sure, where does it located? (tried to search in the settings via the search bar). Should it be enabled? what does it do?

Don’t have it:

My discourse is in Hebrew. Tried to search through the text customized.

Something is wrong with your install, it looks like the install is botched somehow.

Force https is enabled and hidden if let’s encrypt is enabled. There was another topic recently that had http links in summary emailsv(Discourse Activity Summary Emails Guide), Could there be some regression with the code that sets the override env variable? Or something like that?


Hmm maybe. @neil your thoughts?

1 Like

Hmmm didn’t know that.

So @verilog15 do you have a reverse proxy configured?

Can you enter the rails console and check the value of force_https?

I used the following guide to enable HTTPS: Setting up HTTPS support with Let's Encrypt.
Maybe it’s outdated or maybe I should have used another guide? I set there the env “LETSENCRYPT_ACCOUNT_EMAIL”.
New to rails, so is it possible to explain which run in order to check the value of force_https?

This is the same issue as this one (although surfacing under different circumstances)
Having a hostname / full URL in an asset is guaranteed to cause trouble.

In this specific case, the assets were probably built before force_https was turned on.
Rebuild and you’ll be fine.


I tried to rebuild it couple of time but it still keeps that message in the devtools. Maybe something wrong with the app.yml file?

I can’t see the problem though :confused:

ssh root@your.server.ip
cd /var/discourse
./launcher enter app
rails c
puts SiteSetting.force_https
1 Like

I use DigitalOcean and I destroyed the droplet and made a new one. I followed the steps (without using the guide I mentioned before, rather the script). But I still got the same error.
After running the commands I get:


I pushed a change to this file, can you please try an update?


Hey, @falco, Does that change affect Discourse Activity Summary Emails Guide?

EDIT: I was afraid not, but both had to do with force_https, or so it seems to me.

No, my change only affects the URLs for the WorkboxJS library in our service worker file.

Since @verilog15 reports having force_https true already, I assume his problem is what @RGJ suggested.