I am encountering an issue with Angular v17 Server-Side Rendering (SSR) and the ngx-leaflet library in my Angular application. When trying to run the application in an SSR environment, I am getting the following error after build and before prerendering :
"ReferenceError: window is not defined"
I know it's because window isn't accessible on the server side, but I don't use the window object, I think it's due to the use of a function in the library that uses window.
Any idea how to find where to fix it?
Try this.
Code-behind
Generally,
If you are inside a component, use
afterNextRender
If not(when in services, guards, etc...) use
isPlatformBrowser