A space to discuss online store customization, theme development, and Liquid templating.
Hi, this question was asked before, but was never answered. I'm creating an app that uses an applicaiton proxy link. I need to be able to reference this link for AJAX calls, but I cannot rely on the link matching what I set up in my app settings since store owners have the option to edit the url that they use. How can I access the url value that a store is using for my app?
Store owners may choose to change the sub-path so that the URL in the location bar makes the proxy page appear like it is being hosted in their store instead of externally. Ultimately, the sub-path is purely for shop aesthetics and will not affect the actual location of the proxy URL (edited sub-paths will still be forwarded to the proxy URL).
BUMP!
As I create the same pattern as Mr Mackay here I have the same issue. I can set up my App Proxy to work perfect, as /tools or /apps or /a or /community. But as soon as the merchant changes from one to the other, all the JS in the theme no longer points as the right address.
Either you allow the merchant to change URL and allow that change to propagate through a Liquid parameter (if possible), or you send an alert to the App via a webhook so it can re-inject new script code that works with the change.
Leaving the current App Proxy in this state degrades the use case possibilities severely for any App Proxy installed in a general App.
One awesome thing about the App Proxy, which is part of the reason I want to use it, is that you can use it to completely sidestep problems with Cross Origin Resource Sharing in your Javascript. Of course, you should still be authenticating all requests that are made to your app, but this gives you one less complication to worry about.
Another cool thing is that if your App is sending back JSON responses, you can incorporate liquid logic into the response. Based on Andrew's comment at the end of this forum thread, I've been using this ability in an app that I'm developing to verify that each request was made by a logged in customer. If someone were to try to access data from someone else's account by guessing their account ID, the JSON response would be returned as an error message after filtering through the liquid parser.
I have the same issue. I'd like to auto-generate URLs for an email to send which would land on the user's proxy page for my app. However, if they change the Proxy URL, then I have no idea where to send the user who's receiving the email.
Dan
BUMP
Thanks for bringing this up again.
We still need to be able to know when a shop changes our proxy url so we can send out the correct location in emails.
Is this the best place to get support for the API for Partners? I emailed customer support, they told me to come here, but a large number of these posts seem to rot on the vine...
Dan
You can write emails to support@shopify.com, post here. You can try Twitter feeds too.
An email to support resulted in a reply that basically said "We don't have the expertise to help you here, post on the forum or StackOverflow." Hopefully one of these two methods gets some results.
Dan
Sure.. if your issue is simple SO could help. A lot of chuff blows in the wind there too. Lots of off-topic problems lumped in.
Yeah. Unfortunately, none of the three questions I've posted here have gotten any results either.
Dan
Honestly, I wouldn't expect to get any response about this. I have problems going back over 3 years which I've contacted Shopify about multiple times—through the forums, through support, and through twitter—and still they're not addressed. It might be more productive to write your question on a piece of paper and burn it.
If we do get an answer to this, I will happily eat my words 🙂
Ideally, we'd get a notification for a change in proxy url by the shop owner.
For now, I'd set a preference in your app defaulting to the proxy url you set, then let the shop owner change the that pref if they change their proxy url.
Would it be possible to get the proxy url from a request header in your proxy endpoint? (e.g., referer)
There's no reason there can't be a webhook post with the new proxy url information when it's updated. Hell, even a way to query the Shopify API to ask what the current proxy URL is before I write out anything for the customer would be sufficient (even if it is brutish).
Dan
Edit: Nevermind. After the shop owner changes the proxy url, the old proxy url returns a 404 Not Found. How would your app receive a request with the new proxy url?? Silly me.
<del>Get the new proxy from the request params.</del>
Here's a sample log entry from a shopify app's web server receiving a proxy request:
method=GET path="/shopifyproxy/?shop=my-new-example-shop.myshopify.com&path_prefix=%2Fapps%2Fvanityproxyurl×tamp=1430794527&signature=ff7d7e8af8635584f08d097abdd300062f3f6d8507adabc37c9ab5f20fdc3854"
shop: shop's myshopify_domain
path_prefix: the proxy url.
Keep the proxy url somewhere in your db — ideally a column in a model you already query upon proxy request. If path_prefix is different than the proxy url in your db, update it.
That's the best app developers can do for now.
Another vote to fix this problem. I think I may just put a warning on my app that says the app will break if they change the proxy URL.
I understand the rationale of allowing the store owner to set their own URL, but for some apps this doesn't make sense. The app developer should be able to toggle on/off whether the store owner can change it or not.
@Lucas, this is not a server side problem. It is all about the client. If the merchant changes the prefix, the client-side JS is useless.
So either Shopify informs an App of this change, so the App can then adjust the JS (clunky), or Shopify does away with a feature I bet NO ONE uses. Who really cares what the prefix is. My guess is that its a "You think they might need this, but they really don't" legacy.
Bump. This question was never answered. My app extensively uses the app proxy and I'd like to ensure that I have record of the proxy url being used. Shopify Staff is there an API endpoint we can hit to get this up to date information?
I'm having this same problem in 2023. I searched for "proxy" in https://shopify.dev/docs/api/liquid/objects/, but nothing came up, so I have no idea how to retrieve the app proxy url set by the merchant. This is such a big issue because it basically just breaks your app extension if they set a different app proxy url, and the merchant would be completely confused about why it broke.
agreed. its crazy that there isnt a way to find the merchant setting for your own app in the api
Agreed!
Busy with mandatory migration away from the asset API and this is holding me back.
Adding something like `path_prefix` to the existing `app` liquid object would go a long way in helping with this.
Maybe if they just allowed the proxy to use both paths, the one set by the develoer and the one set by the merchant would be enough!