Can I set the Aurelia root based upon browser URL/subdomain?

Hi,

I have a (secured) aurelia application that is accessed through https://app.mydomain.be and would like to build a public part to this application which does not require any authentication, eg. https://pub.mydomain.be. As I want to re-use my (UI) libraries, I’d like to have 1 aurelia application that is able to pick the right root based on the URL the client is using…

So :

app.mydomain.be → setRoot(“private-root”)
pub.mydomain.be → setRoot(“public-root”)

Is this possible?
Any help on this would be very welcome… :slight_smile:

Thank you.

Jochen

Yes, it is possible.
You should decide in the main module which application root is run.
For example:

let startModule = 'modules/public/public-app';

if (authService.isAuthenticated) {
startModule = ‘modules/private/private-app’;
}

return aurelia.setRoot(startModule);

In your case, you could choose your application root by inspecting window.location.href

Best regards

Thanks @ormasoftchile this will probaby work!!

Jochen