Extension-UI app routes not available to external callers?

Hi all –

I’ve been following Shopify’s guide for creating a post-purchase upsell extension (https://shopify.dev/docs/apps/checkout/product-offers/post-purchase/getting-started) and I’m curious if the extension can publish API routes that can be called externally, like from a landing page hosted with Hydrogen & Oxygen?

For example, in the guide I linked, you end up creating routes for “/api/offer” and “/api/sign-changeset”, which are called by the frontend of the app so that some backend tasks can be completed. That makes perfect sense to me and it works as intended.

However, when I tried creating a /api/hello-world route, it works fine for local testing, but when I deploy the app to production via the Partner Dashboard, I can no longer hit that route because a) I don’t know what the URL of the cloudflare worker is and b) requests don’t seem to be redirected from the primary store’s main URL (i.e. storename.myshopify.com/api/hello-world).

What am I missing here? Is there a way to discover what the published URL of your cloudflare worker is? Or am I misunderstanding how the routing / redirection is supposed to work?

Hi Bivers,

Currently, Shopify’s post-purchase extensions are designed to be self-contained and only communicate with the Shopify environment. The routes defined in the extension code are not exposed as public APIs that can be called externally.

The “/api/offer” and “/api/sign-changeset” routes are internal endpoints used by the extension itself and cannot be accessed directly from outside the extension or the Shopify environment. When you deploy your app to production, the app’s server-side functionality runs in a secure environment managed by Shopify (Cloudflare Workers), which is not directly accessible via a public URL or API. This is why you’re not able to hit your “/api/hello” route in production.

If you need to expose public APIs for use with external sites or, you typically do this from a separate backend server, not from within the post-purchase extension itself. You can then use the Shopify Admin API or Storefront API from your backend server to interact with the Shopify platform as needed.

Hope this helps!

thanks Liam, this definitely answers my question.