How can I correctly register a service worker for my app?

I am the developer of an app for Shopify. And at this stage I am trying to run service worker through my app, for web push. In order for me to register a service worker, I need to have access to my js file in the store root (myshop.myshopify.com/sw.js ). I understand that I can’t just add this file to the root of the store, and I tried to solve this problem through the app proxy, but I was disappointed because I can’t use the header service-worker-allowed: / (Shopify security policy - as far as I understood).

The question is, is there a way to register service worker correctly, or some other way? Is it possible in principle to do what I want or not? I will be very grateful for any answer.

Hello, I’ve encountered the same problem today, have you had any progress or any ideas on that issue?

What is the best approach to push service worker file to Storefront?

Same, did you find any solution for this problem

yes try https://wappaa.com/wappstore/push-notifications-shopify/

This is not allowed. If you could serve sw.js from the root of the shop, you would be able to intercept browser requests for /checkout which would break PCI compliance as all checkout page contents/resources must be served by shopify themselves.

The only way you could do something like this would be to run a headless application on a separate domain that is not associated with the shop, then redirect users to the actual shop checkout page hosted by shopify through a different domain.