Custom App url handling for production / staging environments

I’ve recently switched the custom app url config to point to our production server.

I’m wondering how other people manage further development once the app is live, and in use by the production store?

The Shopify custom app allows you to auto-update the settings to point to your cloudflare domain, but this would cause the production traffic to be directed to your local instance of the app, wouldn’t it?

How are other people handling development while also keeping production traffic hitting the hosted server for an application?

If I update the app urls to point to the development instance (e.g localhost), does this affect actual store traffic?

It is common that you will create another app that will act as your development app.

So you will create a new app that is <Your App -Development>. This app will have different API Keys and will point to your development or staging server. And test it on a test or development store.Then you can test your changes without it affecting your production application.

When you are happy with updates you have made to your development app you can push the code changes via source control to your production server.

Hi, thanks for getting back to me.

OK great, and can these two apps (MyApp and MyApp - Development) share the same repo? How would we provide a config for each within the same codebase?

Ideally we’d like only one source of truth for the app code, could you point me towards how I would configure each of these apps from the same codebase?

EDIT

Actually, given the local dev server uses the shopify.app.toml, the other production app would just use env variables on the server. Is this how it’s commonly done?

Thanks again for the help!

1 Like

We have exactly the same question. We’re maintaining two repos connecting to two apps which is obviously an awful approach to environment management. Did you ever figure this out @jahilldev ?

Unfortunately the best we have right now is the one repo → two apps (actually more now, as we have production, staging and each engineer has their own dev app / store).

It’s really not ideal, but it works fairly well.

Hopefully this will be improved in future somehow.

Hi! By apps, do you mean two (or more) Hydrogen Storefronts? If so, how do you handle test data, e.g., placing test orders? If you mean two Shopify Stores, how are syncing collections, products, etc. handled? I am a bit confused on how to setup a proper development environment.

Hey,

So we have:

  • 2x Custom Shopify Apps using the same repo (+1 dev app per engineer)
  • 2x Shopify Stores, one production, one staging (built from the same theme repo, with a staging / production branch)

Every developer has their own dev store, and dev app instance to prevent conflicts between developers working on their own features.

Hopefully that makes more sense. As I say, it’s not ideal, and I feel Shopify could have some kind of environment built in to the Shopify App system to better handle this, but so far so good, the system seems to work ok.

1 Like

Ah I see, thanks for the quick response. Do you use some third-party app to synchronize products across your two stores? I understand the setup, but if the products are unsynchronized I feel like there is a potential for missteps or pitfalls, as the process for editing products or creating new ones must be repeated identical for the two stores.

Good question, but no, we periodically export products from prodution → staging if required, but staging is ultimately just that, the store is purely there to validate changes, so a 121 mapping isn’t required. Things like custom metafields etc are crucial to align correctly, but other content types like product titles, images etc, can be test data (and they are!).

We’ve structured our application to differentiate product types via metafields so we can decouple store content from business logic.

I’m sure there are apps out there that will sync store content between stores, but we haven’t had a need for it.

1 Like

Alright, thanks for helping! Really appreciate it :slightly_smiling_face:

1 Like