I'm trying to make an app to use PWA in Shopify stores, and I'm having an issue to add service worker file automatically when a client install our app, I can't use Asset API as it uses Shopify CDN instead of store domain name, so instead i want to use app proxy (https://shopify.dev/tutorials/display-dynamic-store-data-with-app-proxies) it will work fine but we need the integration to be done automatically when a store install our app so my question is:
Is there an API to add an app proxy when a store installs our app ? or is there another solution to be able to integrate the service worker file in the store (JS file) via API ?
Hello @Kevin_A , Thank you for your answer.
When you create an App to install in a merchant store, you can choose to add extensions to it. One of the extensions is App Proxy. There is no API to setup a Proxy. Instead, it is all done in your Partner App setup.
Note that there are issues with Proxy that may or may not affect your use of ServiceWorkers. The Proxy is pretty good about stripping ALL nefarious or otherwise extras from calls in to the Proxy.
What i understand is that i can add it from my side without asking the client (store owner) to do this! i will try it.
Thank you for your support.
Currently, you can't add a new Service Worker on the root scope via Shopify. As we have been told this is being reviewed.
As such - you won't be able to run a PWA as you need that root scope to allow for the offline caching.
I just use App Proxy the way it was intended, and have zero problems with service workers. Life is good. Proxy is not... it needs a re-factor, but still.. when it works, it does all it needs to do for me.