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


I have a (secured) aurelia application that is accessed through and would like to build a public part to this application which does not require any authentication, eg. 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 : → setRoot(“private-root”) → setRoot(“public-root”)

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

Thank you.


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!!