Skip to main content
All CollectionsGetting startedWeb Push implementation
How to set up Batch web push notifications if I can't put a file at the root of my website?
How to set up Batch web push notifications if I can't put a file at the root of my website?

Some CMS as Magento make it difficult to upload the Service Worker at the root of your website. Find out here how to use Batch with them.

Claire avatar
Written by Claire
Updated over a year ago

1. Declare the service worker's path

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

You need to indicate that the Service Worker is not at the root of the website and declare its path. The parameter serviceWorkerPathOverride is made for this.

You will need to add the following line to your tag's configuration: 

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

2. Check your server's configuration

The server needs to get a successful 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).


This article belongs to Batch's FAQ. Need more help? Find insightful articles, documentation, case & market studies, guides, and even more in our website's Resources section on batch.com and our blog.

Did this answer your question?