I have been searching this for a long time but cannot find a concrete solution.
The problem is like this:
I got a shopify remix app with a theme app extension. The theme app make api request to the shopify app through app proxy. I set something like this:
and making a call like https://test-store.myshopify.com/apps/test-app/get-sth will redirect the api call to https://test-app.domain.com/api/get-sth
which definitely what app proxy is doing.
In my theme extension liquid code, i may need to hard code the url https://test-store.myshopify.com/apps/test-app as a baseUrl for the api call. But the big problem is, merchant can actually change the prefix and subpath for the app proxy, and hard coded URL this will break the app in that case.
i.e. if merchant change the app proxy tohttps://test-store.myshopify.com/a/as-whole
and my app keep sending the api request tohttps://test-app.domain.com/api/get-sth
This is a common challenge and limitation with Shopify app proxies: the merchant can change the app proxy’s prefix and subpath, which means any hardcoded URLs in your theme extension or Liquid code can break if the merchant updates these settings.
I make a app proxy call in my liquid code like fetch(`/apps/test-app/get-sth`)
it will send an api to https://test-app.domain.com/api/get-sth
through the https://test-store.myshopify.com/apps/test-app/get-sth
app proxy.
But i have no way to figure out whether if the subpath /apps/test-app is changed by merchant or not, or at least i cannot find anyone give a concrete solution for this.
And I think it should be one of the designated use case for app proxy right? But there is such a big hole for this without any official suggestion to tackle .
The only place exposed to merchant is just in the Settings > Apps and sales channels, which merchant can modify the subpath over there.
Since your app relies heavily on the app proxy, you should make this clear during installation and provide support documentation for troubleshooting. You could also call this out in the home page UI of your app that changing the app proxy path will break theme integrations and must be kept in sync.
What you could also do if the subpath is changed is, in your frontend code, handle errors gracefully if the proxy endpoint is unreachable, and display a message prompting the merchant to check their app proxy settings.
Because you cannot currently prevent or detect changes to the app proxy subpath via the API these strategies would be the best approach.