Best practice for domain(s)?

We’ve been developing an app on the backendless subdomain… but hard-coding lots of things (links to files) to point to this subdomain. Soon we will want to set a custom domain (perhaps more than one), and then change it when we’re ready to switch over a live app to run on Backendless. For the backend logic in Backendless, there is or was this:

but that doesn’t seem to work anymore (?). Is there something similar for front end logic? So we can point to whatever our domain is, and not hard-code things to point to the Backendless subdomain we’re currently using?

What’s “best practice” for domain(s)?

Hi @Alex_Klein,

The first option is to store your domain in Custom Settings and then get it from settings wherever you need (the first block on the screenshot).
The second option is to refer window location object and take its host part (the second block on the screenshot).

image

Also to avoid constant building of these blocks, I recommend putting them into a custom function and use only a single block everywhere.

Regards,
Stanislaw

Hi @stanislaw.grin thanks for that — I see the window location object has “host”, guess we could use that.

But the “Get Custom App Settings” block is a complete mystery. Printing that to console shows it’s an empty object. How does it work? Can we set/get properties to it? Is it then stored somewhere in the backend of our application? Or is it a temporary thing like “App Data”? Got any link to a page with documentation?

I’m also wondering about Context Blocks. What is “Request Context”, why did “Get customDomain of Request Context” previously return our domain but now it doesn’t return anything? If we create logic in custom API services, how to get our custom domain?

Thanks for your insights :pray:

How does it work? Can we set/get properties to it? Is it then stored somewhere in the backend of our application? Or is it a temporary thing like “App Data”? Got any link to a page with documentation?

You can find it in the Settings tab under the Custom menu.
There is an icon in the top right corner, click it to open the tutorial about this section.
These settings are stored persistently in the files and are not temporary like “App Data”.

why did “Get customDomain of Request Context ” previously return our domain but now it doesn’t return anything?

If you invoke the service using a custom domain, it still returns it.
Otherwise if you invoke the service using App ID & API Key, the customDomain property will be empty in the Request Context.

If you think you’re invoking the service using a custom domain and the customDomain property is empty, please let me know about it, I will have to ask you to provide steps to reproduce it in your app.