Uploading the Service Worker to a folder of your website

Some CMS don't allow you to upload a file directly at the root of your website. In this case, you can upload the file to a folder of your website.

Upload the service worker

Let's say you can only upload the batchsdk-worker-loader.js file to the media folder of your website, the path to this file will be: https://mywebsite.com/media/batchsdk-worker-loader.js.

The server needs to get a success response with GET and OPTIONS methods.

The Service-Worker-Allowed header with the value " /" has to be served. Otherwise, you will need to add it.

You can test it as below, from the terminal, with httpie for example (test with the service worker path).

check server

Declare the service worker path

Add the following line to the JavaScript tag's setup object:

serviceWorkerPathOverride: "/media/batchsdk-worker-loader.js",