how to register Service Worker in Script Tag?

Hi there, I am using shopify script tag to add some functionality to merchant store, so in script tag .js file I am trying to register a service worker but I got the following error:

Show More

Uncaught (in promise) DOMException: Failed to register a ServiceWorker: The origin of the provided scriptURL (‘https://fea3-5-219-49-37.ngrok.io’) does not match the current origin (‘https://pouyas-store.myshopify.com’)

here is my code in embeded javascript file:

const baseURL = "https://fea3-5-219-49-37.ngrok.io";
(function (){
      navigator.serviceWorker.register(baseURL+"/static/shopify_app/ServiceWorker.js")
          .then((reg) => {
            console.log("reg",reg);
              if (Notification.permission === "granted") {
                  getSubscription(reg);
              } else if (Notification.permission === "blocked") {
              } else {

                  $("#GiveAccess").show();
                  $("#PromptForAccessBtn").click(() => requestNotificationAccess(reg));
              }
          });
})()

Hello Pouyasalimian

Hope you are doing well.

Your shop host and ngrok URL do not match. When you installed your app that script tag API inserts your js file. when your site load at that time js file loads. I think you need to destroy old script tag record. Because every time you installed your app that time script tag create new record. Please destroy old record. Then check may be works.