# ServiceWorker script evaluation failed due to HTTP (not HTTPS)

**URL:** https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800
**Category:** Support
**Created:** [August 3, 2019, 7:19pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800 "2019-08-03T19:19:14Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![verilog15](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@verilog15](https://meta.discourse.org/u/verilog15)
#### Post date: [August 3, 2019, 7:19pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/1 "2019-08-03T19:19:14Z")

</div>

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

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/4/b48072f9ef407fa0663be397c16fcc2808789908.png)

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?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 3, 2019, 8:46pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/2 "2019-08-03T20:46:23Z")

</div>

Did you enable `force_https` in the site settings?

---

<div class="post-metadata">

### Author: ![verilog15](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@verilog15](https://meta.discourse.org/u/verilog15)
#### Post date: [August 3, 2019, 8:59pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/3 "2019-08-03T20:59:24Z")

</div>

> [@Falco](#):
>
> `force_https`

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?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 3, 2019, 9:04pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/4 "2019-08-03T21:04:17Z")

</div>

![image](https://global.discourse-cdn.com/meta/original/3X/a/2/a22578dfdcf00a6682a565afa8fccc1c96b18315.png)

---

<div class="post-metadata">

### Author: ![verilog15](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@verilog15](https://meta.discourse.org/u/verilog15)
#### Post date: [August 3, 2019, 9:21pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/5 "2019-08-03T21:21:30Z")

</div>

Don’t have it:

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/4/a4b81698644efda8c39aa7f7fec4dad78cebed8f.png)

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

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [August 4, 2019, 7:26am UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/6 "2019-08-04T07:26:41Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 4, 2019, 9:40am UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/7 "2019-08-04T09:40:54Z")

</div>

Force https is enabled and hidden if let’s encrypt is enabled. There was another topic recently that had http links in summary emailsv([Configuring Activity Summary emails - #29](https://meta.discourse.org/t/discourse-activity-summary-emails-guide/36627/29)), Could there be some regression with the code that sets the override env variable? Or something like that?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [August 4, 2019, 11:44am UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/8 "2019-08-04T11:44:14Z")

</div>

Hmm maybe. @neil your thoughts?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 4, 2019, 3:43pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/9 "2019-08-04T15:43:02Z")

</div>

> [@pfaffman](#):
>
> Force https is enabled and hidden if let’s encrypt is enabled.

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?

---

<div class="post-metadata">

### Author: ![verilog15](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@verilog15](https://meta.discourse.org/u/verilog15)
#### Post date: [August 4, 2019, 5:34pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/10 "2019-08-04T17:34:02Z")

</div>

I used the following guide to enable HTTPS: [Set up HTTPS support with Let's Encrypt](https://meta.discourse.org/t/setting-up-https-support-with-lets-encrypt/40709).  
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?

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [August 4, 2019, 6:02pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/11 "2019-08-04T18:02:01Z")

</div>

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.

> [@Full URL in assets erb file --\> multisite issues](https://meta.discourse.org/t/full-url-in-assets-erb-file-multisite-issues/124393):
>
> The new workbox service worker implementation uses UrlHelper.absolute. Since this is a compiled asset, it stores the full URL, containing the full hostname of the primary host in a multisite environment. [https://github.com/discourse/discourse/blob/master/app/assets/javascripts/service-worker.js.erb#L3-L6](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/service-worker.js.erb#L3-L6) I think it should be using UrlHelper.local\_cdn\_url instead. This also circumvents the need to recompile assets after changing the hostname.

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

---

<div class="post-metadata">

### Author: ![verilog15](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@verilog15](https://meta.discourse.org/u/verilog15)
#### Post date: [August 4, 2019, 6:21pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/12 "2019-08-04T18:21:15Z")

</div>

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?

 ![image](https://global.discourse-cdn.com/meta/original/3X/8/b/8b850c5748958bcfd1788c74ce2823ffb8617cfe.png)  
 ![image](https://global.discourse-cdn.com/meta/original/3X/a/0/a04cbebe2b08fa723458a197ecdbfeae3289748d.png)  
 ![image](https://global.discourse-cdn.com/meta/original/3X/b/8/b8df9099db367acf0d2099b281ee39ec0c605d93.png)  
I can’t see the problem though 😕

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 4, 2019, 7:31pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/13 "2019-08-04T19:31:54Z")

</div>

> [@verilog15](#):
>
> New to rails, so is it possible to explain which run in order to check the value of force\_https?

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

```

---

<div class="post-metadata">

### Author: ![verilog15](https://avatars.discourse-cdn.com/v4/letter/v/9f8e36/32.png) [@verilog15](https://meta.discourse.org/u/verilog15)
#### Post date: [August 4, 2019, 9:09pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/14 "2019-08-04T21:09:41Z")

</div>

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:  
 ![image](https://global.discourse-cdn.com/meta/original/3X/f/d/fd8b6dc917047021ec3b4619b03d1d87b2006861.png)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 5, 2019, 10:45pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/16 "2019-08-05T22:45:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 5, 2019, 10:53pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/17 "2019-08-05T22:53:02Z")

</div>

Hey, @falco, Does that change affect [Configuring Activity Summary emails - #32](https://meta.discourse.org/t/discourse-activity-summary-emails-guide/36627/32)?

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

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 5, 2019, 11:00pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/18 "2019-08-05T23:00:04Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [February 10, 2023, 5:19pm UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/19 "2023-02-10T17:19:37Z")

</div>



---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 11, 2023, 6:57am UTC](https://meta.discourse.org/t/serviceworker-script-evaluation-failed-due-to-http-not-https/124800/20 "2023-02-11T06:57:51Z")

</div>


