Open ev45ive opened 5 months ago
Temporary Fix:
oauth = inject(OAuthService)
pid =inject(PLATFORM_ID)
ngOnInit(): void {
if(isPlatformBrowser(this.pid))
this.oauth.tryLogin()
}
export const authConfig: AuthConfig = {
// URL of the SPA to redirect the user to after loginemv
redirectUri: globalThis.location?.origin + '/callback',
@ev45ive Hey just came across this issue, I'm getting console errors saying the window is not defined whenever I do ng serve. is there a chance you can elaborate on this?
I tested the whole login flow and it is working. I'm looking at your temporary fix and I'm not sure where I'm supposed to place the first snippet of code you posted. I already adjusted the authConfig to have it look like yours. Again, I'm just not sure where in my code I need to place the first part.
Angular 17 enabled SSR and prerender by default and this library uses
window
, notglobalThis
and doesn't detect if in SSR/Edge so programmer has to those checks and wrap things withisPlatformBrowser()
checks.I am not sure if whole server side flow is planed in scope of this library, but making
tryLogin
/initLoginFlow
a NO-OP in SSR? maybe?