angularserver-side-renderingangular-universaltradingview-apidatafeed

Integrate Trading view with Angular 10 universal SSR


Hi I have integrated trading view libraries for Angular 10 client side rendering. Recently I want to do SEO for my website so had implement trading view in Angular 10 universal.

Here main issue is when I load trading view first time it loads perfectly. But when i load for the second time it gives "window is not defined" errorintegrated console error

I have imported datafeeds in index.html index.html

please check my ts.app.config ts.app.config

what more do i have to add to make it work on angular 10 universal??


Solution

  • Like I said in my comment, you can try using domino to provide a mock for window object, especially for 3rd party libs

    server.ts

    //imports ...
    
    const domino = require('domino');
    const win = domino.createWindow('/path/to/your/project/dist/client/index.html');
    global['window'] = win;
    global['document'] = win.document;
    global['navigator'] = win.navigator;
    
    //...
    //start express server as usual