Shopify Admin API App proxy

AI-generated summary

Le sujet porte sur l’intégration automatique d’un fichier service worker pour une PWA dans une boutique Shopify, au moment où un marchand installe l’app.

  • La question centrale : existe-t-il une API Admin pour créer/configurer un App Proxy automatiquement, ou une autre méthode API pour servir un fichier JS de service worker depuis le domaine de la boutique ?
  • Une première piste proposée est ScriptTag, mais elle est jugée insuffisante ici car un service worker doit être servi depuis le même domaine que la boutique.
  • Réponse principale : il n’existe pas d’API pour configurer un App Proxy. Celui-ci se règle côté Partner Dashboard, comme extension de l’app, et non via l’Admin API.

Points importants soulevés :

  • L’auteur comprend qu’il peut donc préparer cela côté app, sans intervention manuelle du marchand.
  • Un avis indique qu’il n’est actuellement pas possible d’ajouter un service worker avec scope racine sur Shopify, ce qui bloquerait les fonctions PWA comme le cache offline.
  • Un autre retour dit utiliser App Proxy avec des service workers sans problème.

Conclusion : la configuration d’App Proxy est clarifiée, mais la faisabilité complète d’une vraie PWA reste ouverte et discutée.

Hello,

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 ?

Thank you.

Hey @abdelilah

If all you need to do is inject some javascript on the storefront, I would check out ScriptTags: https://shopify.dev/docs/admin-api/rest/reference/online-store/scripttag

Hello @Kevin_A , Thank you for your answer.
Yes i saw the ScriptTag API, but actually i need to insert a service worker file, it’s a javascript file but have to be in the same domain as the store, so i thought about using app proxy but i don’t see in the Admin API documentation if we can add an App proxy using the API

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.

Hi,

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.