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

Show an example on how to use APP_INITIALIZER to set AuthConfig #1058

Open
guidoffm opened this issue Apr 14, 2021 · 2 comments
Open

Show an example on how to use APP_INITIALIZER to set AuthConfig #1058

guidoffm opened this issue Apr 14, 2021 · 2 comments
Labels
docs Issues that involve improving or adding documentation.

Comments

@guidoffm
Copy link

guidoffm commented Apr 14, 2021

At the moment all examples use configuration in code.

If you want to package your app and want to deploy it to different environments this is not optimal.
It would be better to load the configuration at runtime.

I will offer an example by myself soon.

@jeroenheijmans jeroenheijmans added the docs Issues that involve improving or adding documentation. label Apr 15, 2021
@jeroenheijmans
Copy link
Collaborator

Examples are always welcome I think!

Curious to hear also what the practical use case would be to do it in the initializer? I find that to use Angular's environment I can just use this setup:

{ provide: AuthConfig, useValue: myConfigUsingEnvironment }

or alternatively with useFactory instead.

We actually use a factory in one of my applications, that contains some logic to look at window.location.hostname to tweak some things in the config.

Either way, would be nice to see an APP_INITIALIZER example too!

@guidoffm
Copy link
Author

Here is the sample app:

https://github.com/guidoffm/sample-angular-oidc-with-app-initializer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Issues that involve improving or adding documentation.
Projects
None yet
Development

No branches or pull requests

2 participants