angular-auth-oidc-client icon indicating copy to clipboard operation
angular-auth-oidc-client copied to clipboard

[Question]: Angular 17 with SSR (Universal)

Open m-prolic opened this issue 1 year ago • 1 comments

What Version of the library are you using? 17.0.0

Angular version: 17.1.2

provideRouter( routesAuth,withPreloading(PreloadAllModules), withInMemoryScrolling({ scrollPositionRestoration: 'enabled' }), withEnabledBlockingInitialNavigation() ), provideAuth(authConfig), { provide: AbstractSecurityStorage, useClass: LocalStorage }, provideHttpClient(withFetch(), withInterceptors([authInterceptor(), agoraLoadingInterceptor])), .....

export const authConfig: PassedInitialConfig = { config: { triggerAuthorizationResultEvent: true, postLoginRoute: '/home', forbiddenRoute: '/forbidden', unauthorizedRoute: '/unauthorized', logLevel: LogLevel.Debug, historyCleanupOff: true, authority: 'https://demo.duendesoftware.com/', redirectUrl: 'http://localhost:4200/', postLogoutRedirectUri: 'http://localhost:4200/', clientId: 'interactive.public', scope: 'openid profile email api offline_access', responseType: 'code' }, }; We are using Authorization Code + PKCE - Duende identity server

Question

Does the library support Angular 17 with SSR ?

I am getting the next errors in the SERVER console:

image

image

Is it possible to get pages authorized/guarded rendered in SSR?

I've tried to implement Cookie Storage and provide it to app.config.server.json, but I am still getting messages that Storage is falsy/undefiend.

` const serverConfig: ApplicationConfig = { providers: [provideServerRendering(), provideHttpClient(), { provide: LocalStorage, useClass: ServerStorage }], };

export const config = mergeApplicationConfig(appConfig, serverConfig); `

m-prolic avatar Feb 05 '24 14:02 m-prolic

The first issue seems related to this Code https://github.com/damienbod/angular-auth-oidc-client/blob/main/projects/angular-auth-oidc-client/src/lib/utils/crypto/crypto.service.ts

It seems like the angular domino browser (server side) has no crypto property. This only happens on the server side.

Desnoo avatar Apr 26 '24 22:04 Desnoo