How do I customize app based on hostname?


#1

We are developing a multi-tenant application that is going to be set up on our customers’ domains. Each of our customers require a custom color scheme and text for their login screen. Of course, once they have logged in I can easily make an AJAX call and fetch all of the other dynamic content and formatting from the database, I just want to make sure that the user sees the right thing from the start of their experience.

Is there any way to get EmberJS to drive this from the incoming hostname?

As an aside, it would be great to see a multi-tenant design guide :grinning:


#2

I think that if your multi-tenant grows you would also need separate databases. It is therefore better to specify an environment containing the login color scheme so you can switch databases easily also. To do this take a look at https://github.com/offirgolan/ember-host-manager


#3

I have the database partitioning and clustering strategy already, we have a lot of experience in that area - it’s EmberJS that we’re coming up to speed on. For what it’s worth I had this working perfectly in a node/express prototype before we decided to port over to EmberJS.

It’s good to know that there is some sort of hostname conditional processing, I’ll look into ember-host-manager to see how deep it goes, but at first glance it seems to be completely client-side and manual config.

Are there any other possible solutions for pre-processing EmberJS? Is Fast Boot ready for something simple like this?


#4

We store the Ember app in the database with ember-cli-deploy-couchdb so it can be specific for each customers. You can setup this on IBM’s cloudant. If you want to do this on a classic backend I think that you can change the environment in the generated <meta name="myapp/config/environment" content="....."/> in index.html. Never tested this.


#5

Thank you. I’d appreciate knowing more details on how you look up the data for each hostname as part of the request process. There is very little documentation about this out there.

We’re in Azure so this project is looking like the right one to do this:


#6

We just use ember-cli-deploy for each customer because the applications are in separate cloudant databases.

I created a test for your case. If you do the following:

So it is possible to set your tenant on the backend based on hostname and do customization based on that.