Shopify Admin API App proxy

abdelilah
New Member
3 0 0

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.

0 Likes
Kevin_A
Shopify Staff
Shopify Staff
310 42 53

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

Kevin_A | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

abdelilah
New Member
3 0 0

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

0 Likes
HunkyBill
Shopify Expert
4505 46 491

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.

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
abdelilah
New Member
3 0 0

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.

0 Likes
Edgemesh
Tourist
6 0 3

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.

 

0 Likes
HunkyBill
Shopify Expert
4505 46 491

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.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes