problem with allowedUrls and AOT
See original GitHub issueI have a problem with allowedUrls in :
OAuthModule.forRoot({
resourceServer: {
allowedUrls: [varFromConf],
sendAccessToken: true
}
})
I want to pass a variable to it because it come from configuration stuff but when it’s compile by AOT my variable is replaced by null and so authorization token is not sent later.
Is there any workaround for this problem ? I dont want to hard code here my allowed urls…
for the moment what I did is to iOAuthModuleConfig from may main app.component and then set resoureServer from there.
constructor(private moduleConfig: OAuthModuleConfig) {
this.moduleConfig.resourceServer.allowedUrls = [(<any>window).ServerConfig.ApiBaseUrl];
}
But I don’t know if it’s a good thing
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Angular load external configuration before AppModule loads
Load configuration parameters (API server URL and Auth server URL) from an external endpoint (JSON), before the AppModule is loaded; Pass ...
Read more >The Biggest Problem In “Tokyo Ghoul” And “Attack on Titan”
In Tokyo Ghoul, that's the ghouls, who look like humans, act like humans, and camouflage with human society, but have to eat humans...
Read more >Everyone Loves Attack on Titan. So Why Does ...
A big, recurring controversy in the fandom is figuring out how to discuss or even deal with these issues at all. As a...
Read more >Angular load external configuration before AppModule loads
In addition to @yurzui's answer, if you try this in AOT (e.g. ng build --prod ), you will get. ERROR in Error during...
Read more >What exactly does allowedUrls setting mean in the ...
Issue. So, if my Angular app is running on localhost:4200 & keycloak server running on localhost:8080/auth, which URL values should I add in ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I suggest doing this in
app.module.ts
:and then this in
auth-config-factory.ts
:or something similar…
I faced the same problem and found a different solution. The problem with initializing your setting using APP_INITIALIZER is that loading the configuration is mostly async (using a promise) and the factory methods in your module are called before this promise is resolved.
You can however load the settings BEFORE bootstrapping the Module. Inside your App.module/other components you can access your settings without having to fear the settings are not loaded. I have created an example of how to accomplish this: github.com/dtiemstra/AngularConfigDemo