Closed Aravinthan27 closed 2 years ago
There i s a solution for this problem?
Yes, @ng-idle/core does not work with Angular universal / platform-server as of v2.0.0-beta.15 and Angular 5.2.9.
The problem code is in node_modules/@ng-idle/core/bundles/core.umd.js
, ~175
The reference to document fails on the server
You need to check if document exists before referencing it. Since the server code would never need to time out, I would think ideally if it's invoked on the server it should just give up and not set up any timers, etc.
The same situation exists in node_modules/@ng-idle/core/src/windowinterruptsource.js
, must check for window before accessing it
If you are using SSR/Universal, following this change you should no longer use DEFAULT_INTERRUPTSOURCES
.
Instead, create your own instances of desired sources, or use createDefaultInterruptSources({ ssr: !isPlatformBrowser(platformId) })
. The ssr
option (which can be used alongside the other EventTargetInterruptOptions
you desire) should be false
when running in the browser, and true
when running on the server. You can use isPlatformBrowser
or isPlatformServer
to determine which the app is running in.
DEFAULT_INTERRUPTSOURCES
is equivalent to createDefaultInterruptSources({ ssr: false })
, meaning they will not run on SSR/Universal (which is the current/default behavior).
I am using ng2-idle in my Project. It is working fine when running the project using ng serve.
But when i try to take build using
npm start
causing the error