I put together a PoC to test the angular universal with auth0 and I experience the following error when I navigate to the server side rendered path:
Router Event: NavigationError
NavigationError(id: 1, url: '/auth', error: ReferenceError: location is not defined)
NavigationError {
id: 1,
url: '/auth',
error: ReferenceError: location is not defined
at shouldHandleCallback (webpack:///node_modules/@auth0/auth0-angular/fesm2020/auth0-auth0-angular.mjs:457:19)
at constructor (webpack:///node_modules/@auth0/auth0-angular/fesm2020/auth0-auth0-angular.mjs:289:14)
at factory (webpack:///node_modules/@auth0/auth0-angular/fesm2020/auth0-auth0-angular.mjs:465:17)
at getNodeInjectable (webpack:///node_modules/@angular/core/fesm2022/core.mjs:4391:44)
at searchTokensOnInjector (webpack:///node_modules/@angular/core/fesm2022/core.mjs:4318:16)
at lookupTokenUsingNodeInjector (webpack:///node_modules/@angular/core/fesm2022/core.mjs:4267:34)
at getOrCreateInjectable (webpack:///node_modules/@angular/core/fesm2022/core.mjs:4179:23)
at Module.ɵɵdirectiveInject (webpack:///node_modules/@angular/core/fesm2022/core.mjs:11996:19)
at NodeInjectorFactory.AuthComponent_Factory (webpack:///apps/angular-universal/src/app/pages/auth/auth.component.ts:30:27)
at getNodeInjectable (webpack:///node_modules/@angular/core/fesm2022/core.mjs:4391:44),
target: RouterStateSnapshot {
_root: TreeNode { value: [ActivatedRouteSnapshot], children: [Array] },
url: '/auth'
},
type: 3
}
ERROR ReferenceError: location is not defined
at shouldHandleCallback (./node_modules/@auth0/auth0-angular/fesm2020/auth0-auth0-angular.mjs:457:19)
at constructor (./node_modules/@auth0/auth0-angular/fesm2020/auth0-auth0-angular.mjs:289:14)
at factory (./node_modules/@auth0/auth0-angular/fesm2020/auth0-auth0-angular.mjs:465:17)
at getNodeInjectable (./node_modules/@angular/core/fesm2022/core.mjs:4391:44)
at searchTokensOnInjector (./node_modules/@angular/core/fesm2022/core.mjs:4318:16)
at lookupTokenUsingNodeInjector (./node_modules/@angular/core/fesm2022/core.mjs:4267:34)
at getOrCreateInjectable (./node_modules/@angular/core/fesm2022/core.mjs:4179:23)
at Module.ɵɵdirectiveInject (./node_modules/@angular/core/fesm2022/core.mjs:11996:19)
at NodeInjectorFactory.AuthComponent_Factory (./apps/angular-universal/src/app/pages/auth/auth.component.ts:30:27)
at getNodeInjectable (./node_modules/@angular/core/fesm2022/core.mjs:4391:44)
Although, the auth0 login works but the page is not rendered server side which is what I want to achieve.
I did stumble upon this stackoverflow article but unfortunately this did not help to resolve the issue I’m facing.
Any help would be appreciated, cheers!