grumar / adal-angular5

Angular 5 ADAL Wrapper
MIT License
12 stars 19 forks source link

Errors when server side rendering is enabled. #19

Closed pvsherman closed 6 years ago

pvsherman commented 6 years ago

If in my Index.cshtml this line of code is present: <app asp-prerender-module="ClientApp/dist/main-server">Loading...</app> I get an error:

_NodeInvocationException: window is not defined
ReferenceError: window is not defined
at Adal5Service.init (_

If I move Adal5Service declaration from app.module.server to app.module.browser the error changes to:

_NodeInvocationException: StaticInjectorError(AppModule)[AppComponent -> Adal5Service]: 
StaticInjectorError(Platform: core)[AppComponent -> Adal5Service]: 
NullInjectorError: No provider for Adal5Service!
Error: StaticInjectorError(AppModule)[AppComponent -> Adal5Service]: 
StaticInjectorError(Platform: core)[AppComponent -> Adal5Service]: 
NullInjectorError: No provider for Adal5Service!_

But if I replace line <app asp-prerender-module="ClientApp/dist/main-server">Loading...</app> with line <app asp-ng2-prerender-module="ClientApp/dist/main-server">Loading...</app> in file Index.cshtml - Everything works fine.

Is this an expected behavior or is this an error? Thank you.

grumar commented 6 years ago

If You using asp-prerender-module, probably any angular library which is using window object will throw exception Please read this issue it may be helpfull.