Using the latest Angular how can one accomplish this, creative ideas are welcome.
Angular project with the following modules which are lazy loaded (limiting to two modules just for brevity sake but there could be a lot more):
- UsersModule
- AdminModule
For the AdminModule I would like to apply additional security, mainly I would like to IP protect it. Which given the architecture design (specific to this case) means it needs to be served from another server (so different host than the other modules).
So basically this means:
- UsersModule - on host A (open to everyone)
- AdminModule - on host B (ip protected)
Give this scenario, how can one modify the download url Angular uses specific to the AdminModule?
Is there a way to intercept the download url Angular uses and modify it or somewhere in Angular to set a specific download url to use?
Note The AdminModule is already lazy loaded only for admins. So if your recommendation is to load it conditionally that is already done.
Note Server side the actions that the AdminModule makes have the additional security like IP protection so if your recommendation is that then that is already done, this question is only for downloading of the module client side.
Update 0
Note Using a proxy/server side solution to intercept the request and rewrite it is not possible given the design. The question is regarding how to implement it client side.
Update 1
It appears that it is possible to create a custom ResourceLoader and then provide it to Angular overriding the default implementation.
For example something like:
const providers = [{provide: ResourceLoader, useClass: MyResourceLoaderImpl}];
platformBrowserDynamic().bootstrapModule(AppModule, {providers});
Here is an example of an implantation of ResourceLoader.
However, trying it with with my app doesn't work. However, that seems like it should, am I missing anything?