Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The config.json is not finished loading before other modules are! #52

Open
atarazavi opened this issue Jan 10, 2023 · 3 comments
Open

Comments

@atarazavi
Copy link

atarazavi commented Jan 10, 2023

I'm facing the same issue as mentioned in the documentation:

In some cases, the config.json is not finished loading before other modules/services are, so the above methods will return null. If that is the case, subscribe to the configSubject and access the configuration object that way.

I'm using runtime-config-loader to load the config file for angular-auth-oidc-client's AuthModule!
but I couldn't use configSubject and couldn't find any sample code for using it! Maybe a sample code solves my problem!
I mean I tried subscribing to configSubject but it's still null!

image

@pjlamb12
Copy link
Owner

What I do for this is put the auth config inside the config.json file that is loaded in RuntimeConfigLoaderModule. And then in the code I get the authConfig from the service, and call the configure method from the OAuthService.

//app.component.ts

const authConfig = this._config.getConfigObjectKey('authModuleConfig');
this._oauth.configure(authConfig);

Does this answer the question? I've used this several times, in several apps, and it always works.

@atarazavi
Copy link
Author

Thank you for your response!
I think it doesn't answer in this case :(
In app.component.ts I have access to the loaded config files, the problem is with the AuthConfigModule which is a Module.
I can't put a module inside the config.json file.
I need the config data which is in the config.json file, inside the AuthConfigModule.
Here is the AuthConfigModule:
image

and the identityConfigFactory:
image

As you can see, I need the runtime config loaded data inside the AuthConfigModule's factory! But it's null because it's not loaded yet!
How can I use the method/trick you mentioned to force this module to wait for RuntimeConfigLoader to load config.json file?

@pjlamb12
Copy link
Owner

I don't know exactly how you're loading the Auth configuration, but like I said, in my app.component.ts file I get the auth config, and then use the OAuthService to set the configuration. This works just fine for me each time.

I don't know of any way to make the AuthModule wait to load until the RuntimeConfigLoaderModule has loaded.

In your case, if you're trying to load the config from a JSON file in that factory, I'd just load the JSON file directly and not try to get it from the runtime config loader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants