#Internal server error: document is not defined in Angular@17.0.0 SSR
12 messages · Page 1 of 1 (latest)
Hello , if thried library the only solutions if usage isPlataformBrowser for indicate the code only execute in browser , because remember the SSR execute between Server & Browser but some library usage global object like window or document only exist in browser.
If is your own library considere usage DOCUMENT in contructor or inyect
// Usage plataformBrowser
https://www.geeksforgeeks.org/angular10-isplatformbrowser-function/
// Usage DOCUMENT
https://www.c-sharpcorner.com/blogs/quick-tip-injecting-document-in-angular-component
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
Yeah both solutions are applied to my project where it's needed, but I can't interact with this third party library that isn't SSR friendly, and thought a polyfills would help but didn't manage to create a working one, and I can't change this library's interactions with document
As I remember, at the time it was not possible to do almost anything to make the library SSR Friendly in Angular Universal, unless you modify it yourself or force it to only be executed in the browser (which is the most viable).
Even in my case I had to create a fork of the library and make it compatible with Angular Universal on my own as a last option.
Ok so I have the choice between forking the library that has the problem and finding an equivalent new one that doesn't use "document"
And there is no way to create a polyfills ?
As far as I investigated a few months ago it was not possible, the closest thing was the "Domino" DOCUMENT that is already being implemented in Angular with Inject
ohter options if remember good if it's only a page not need SSR is possible only send how JS , That is, it does not render the server, only the JS, so to speak.
Well, ok thanks, I should be able to patch this by finding another library cause it's just quill.js that is an html editor so shouldn't be hard to find an equivalent, but seems like that wouldn't be the only error trying to make SSR work xD
Got problems with PWA too sooooo ...
And zone.js imports xD
Could you not render that component on the server?