I am breaking my head for 2 days now to find a way I could read a config.json file in my assets folder.
I tried reading this file while bootstrapping in main.ts so I could somehow use the value in my AppModule in a block like this:
imports: [ ...
AuthModule.forRoot({
config: {
authority: 'https://xxxxxxx',
clientId: 'xxxxxxxxx',
logLevel: LogLevel.Debug,
postLogoutRedirectUri: window.location.origin,
redirectUrl: window.location.origin,
responseType: 'code',
scope: 'openid profile email offline_access',
secureRoutes: ['THIS_IS_WHERE_I_WANT_TO_ADD_THE VALUE_IN_MY_CONFIG_FILE'],
silentRenew: true,
useRefreshToken: true
}
}),
...
I am able to read it in my main.ts and provide the value to the application. I just cannot find a way to use it in the imports array of the App module.
I tried environments but I got stuck on NX project.json not supporting the fileReplacement any more, and a lot of sites suggest environments should not be the way to go, because you do not want to make a separate build just for each environment (while the only difference is just a couple of settings)
So trying runtime configuration, which sounds ideal. I tried many suggested articles about using APP_INITIALIZER or fetching json in main.ts with plain javascript because at that point there is no framework loaded yet.
And all these runtime options actually worked, in that the config data can be accessed a a singleton thoughout the application. Just only not at my specific place in the AppModule, where some modules need to eagerly be passed some config data forRoot.