App running in dev or prod?

I’m looking for a way to programmatically detect if my app is running in ‘development’ or ‘production.’
It appears that (in Device API) both ‘Get Window Location’ and ‘Get Current Url’ return useful information:
Development (UI Builder)
Development

Production (Published)
Published

My questions:

  • ‘ui-builder’ (in the string) seems to show development, absence indicates production. Is this reliable?
  • the two returns look the same. Is one better than the other?

Hello @Jim_Austin

I’ve created an internal ticket BKNDLSS-29305 to add the ability to get this info
Workarounds:

  1. Prod and dev app has different URL, you can create logic based on this info
  2. You can create “Custom code” with name “isProduction” that return return !!BackendlessUI.config.pages (This is a hack. We do not guarantee that we will not change this behavior.)

Regards

‘Window Location’ and ‘Current URL’ both return the same string.

  • is one better to use than the other?
  • will this always be the case?

Hello @Jim_Austin!

As Victor said, you can use a hack like this, but we cannot guarantee that the behavior will not change in the future. I can only recommend that you wait until this functionality is implemented and build your logic around it.
We will let you know as soon as an internal ticket BKNDLSS-29305 is ready.

Regards,
Alexander

Hello @Jim_Austin

We have added a new “Is App In Production?” block that will solve your issue. You can find it in UI Library → App → “Is App In Production?” Block.

Regards,
Bohdan