Closed consigliory closed 7 years ago
It looks like ng2-webstorage is not compatible with angular2-universal. It seems angular2-cookies has support for universal. You can switch from using local storage to cookie storage by overriding the tokenStore
provider in your app.module.ts
.
providers: [
{
provide: StormpathConfiguration, useFactory: stormpathConfig
},
{
provide: 'tokenStore', useClass: CookieTokenStoreManager
}
]
If that doesn't work, you could try implementing your own TokenStoreManager
.
you absolutely right. ng2-websorage does not support universal. I replaced it with their store https://github.com/MarkPieszak/aspnetcore-angular2-universal/blob/master/Client/shared/cache/storage/storage.service.ts#L16-L21
If this works for you, please close this issue.
I using template https://github.com/MarkPieszak/aspnetcore-angular2-universal. first request after server started is fine and reload it throw this error
Exception: Call to Node module failed with error: ReferenceError: window is not defined at Ng2Webstorage.initStorageListener (/Users/roman_petrenko/git/source/elixir/node_modules/ng2-webstorage/bundles/core.umd.js:354:13) at new Ng2Webstorage (/Users/roman_petrenko/git/source/elixir/node_modules/ng2-webstorage/bundles/core.umd.js:332:14) at NgModuleInjector.AppServerModuleInjector.createInternal (/AppServerModule/module.ngfactory.js:576:28) at NgModuleInjector.create (/Users/roman_petrenko/git/source/elixir/node_modules/@angular/core/bundles/core.umd.js:8979:80) at NgModuleFactory.create (/Users/roman_petrenko/git/source/elixir/node_modules/@angular/core/bundles/core.umd.js:8953:22) at /Users/roman_petrenko/git/source/elixir/node_modules/@angular/core/bundles/core.umd.js:8523:65 at ZoneDelegate.invoke (/Users/roman_petrenko/git/source/elixir/node_modules/zone.js/dist/zone-node.js:229:26) at Object.onInvoke (/Users/roman_petrenko/git/source/elixir/node_modules/@angular/core/bundles/core.umd.js:4427:41) at ZoneDelegate.invoke (/Users/roman_petrenko/git/source/elixir/node_modules/zone.js/dist/zone-node.js:228:32) at Zone.run (/Users/roman_petrenko/git/source/elixir/node_modules/zone.js/dist/zone-node.js:113:43) at NgZone.run (/Users/roman_petrenko/git/source/elixir/nodemodules/@angular/core/bundles/core.umd.js:4296:66) at PlatformRef._bootstrapModuleFactoryWithZone (/Users/roman_petrenko/git/source/elixir/nodemodules/@angular/core/bundles/core.umd.js:8521:27) at PlatformRef.bootstrapModuleFactory (/Users/roman_petrenko/git/source/elixir/node_modules/@angular/core/bundles/core.umd.js:8504:25) at NodePlatform.bootstrapModule (/Users/roman_petrenko/git/modules/platform-node/node-platform.ts:505:31) at NodePlatform.serializeModule (/Users/roman_petrenko/git/modules/platform-node/node-platform.ts:153:12)