What's your biggest current challenge? Have your say in Community Polls along the right column.

App proxy endpoint is never hit

App proxy endpoint is never hit

bloodyalbatross
Shopify Partner
9 0 1

I had to change the URL of our Shopify App and now no request goes to our app server anymore. That is, the embedded admin page, which is served from the same server, works. But any fetch() on the store page now just gives 404 with empty body and our server is never hit. So now our app is defunct. Great. Any clue on how that can be fixed? I of course tested the proxy URL in a browser: works of course. But the fetch() that previously worked doesn't anymore.

Replies 6 (6)

isque
Shopify Partner
7 0 1

Hi @bloodyalbatross 

You mentioned both app url and proxy. So just to be sure. When you say you updated the app url do you mean the main url that shopify uses to connect to your embedded app, or the proxy url?
https://shopify.dev/docs/apps/build/online-store/display-dynamic-data

 

If its the app proxy, one thing that has tripped me up in the past is not having the path and subpath in the app configuration matching what the javascript is doing on the storefront.

 

isque_0-1732847250053.png

For example lets say you pick subpath prefix 'apps' and subpath 'foo'.

For proxy url, in this example you are using:
https://myserver.com/

 

To make a request to the endpoint "/hello" on your server, going through the app proxy, you would need to use the url:
"/apps/foo/hello"

Hope that helps. I'm not 100% sure if that's the question you were asking.

 

 -- Adam

bloodyalbatross
Shopify Partner
9 0 1

All of them. And I also delete the app proxy entry, saved, created a new app proxy entry, saved, changed it to a different url, saved, changed back, saved etc. No change.
In the demo store I did some change to the theme and saved, because sometimes that triggers some cache eviction or something that finally applies changes, but this time it didn't do anything.

HOWEVER, I also deleted the app from the demo store and added it back again. Now it works! But that's not good if customers would have to do that to un-break their store when we update something!

isque
Shopify Partner
7 0 1

Ok wow. Yeah I have not seen that problem. For kicks, I just changed a dev app's url,  but the proxy kept working.  When the urls are changed, shopify deploys a new version. Is it possible the shopify cli was running and pushing a new dev version that somehow overwrote the version  you though you had live?

 

I suspect you've looked at this already, But you can go back to those versions in the partner dashboard and expand the 'configuration' dropdown and it'll show you what it should have been using for app url, app proxy etc.. . If those all look correct, and no cli was running, maybe there is an app proxy bug lurking in here.

 

isque_0-1732850084408.png

 

bloodyalbatross
Shopify Partner
9 0 1

The fetch() just calls a relative URL. (/app/foo-bar-baz/endpoint) I.e. deploying a new version of the extension wouldn't change anything. Among the many things that I've tried was of course deploying a new version of the theme extension. And no, the shopify cli wasn't running. When developing I connect to a different app (development app) anyway.

isque
Shopify Partner
7 0 1

I just meant that when you make a url change in the partner portal, you get a new version of your app deployed. Each version will show the configuration setting so maybe there is a clue in there. Yeah I'm using the relative url also so that seems fine.

 

Sorry, not sure what else it might be.

isque
Shopify Partner
7 0 1

btw. I just ran into a version of this problem. I continued to get a 404 when calling fetch from the storefront to my app proxy url even though I double checked it was correct in the .toml and in the partner dashboard.

 

It turns out I had "automatically_update_urls_on_dev = true" in my toml file and that changes *all* the urls including the app proxy. But it seems like when it would change, I couldn't always see it immediately in the partner dashboard. Setting it to false, and resetting the correct proxy server url worked in this case. The only downside is that I'll need to configure the local tunnel differently since the default cli tunnel with cloudflare is always getting a new url on each restart.

Here's the change in the .toml

[build]
automatically_update_urls_on_dev = false