What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Shopify Admin API App proxy

Shopify Admin API App proxy

abdelilah
Visitor
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.

Replies 6 (6)

Kevin_A
Shopify Staff
318 42 61

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 | Solutions Engineer @ 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
Visitor
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

HunkyBill
Shopify Partner
4853 60 568

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
abdelilah
Visitor
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.

Edgemesh
Tourist
9 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.

 

HunkyBill
Shopify Partner
4853 60 568

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