I’ve 2 remote apps app1
and app2
and a shell app myapp
, since all the applications will be behind a proxy, each app is distinguished by base-href i.e, /app1
,/app2
and /myapp
respectively. From app1
App1Module is exposed as a remote which has app1.component which loads data from relative path of app1
from ./assets/config.json
, the code snippet to load the config.json is as shown below.
export class App1Component implements OnInit {
message: string[] = [];
constructor(private http: HttpClient) {}
ngOnInit(): void {
this.http.get<any>('./assets/config.json').subscribe(v => (this.message = v.info));
}
}
Now when I try to access the remote app directly using http://localhost:4201/app1/#/home, it is able to read the data from config.json, where /app1
is baseHref
However when I enable module federation and import App1Module
to shell app ‘myappand try to load
app1.component, since the relative path is provided
myappadds its base href and tries to load the file from
http://localhost:4200/myapp/assets/config.jsoninstread of
http://localhost:4201/app1/assets/config.json`
Question: How to retain the baseHref of imported remote module in shell when relative path is used in remote module?
Example project can be found here