AgoraIO-Community / Angular-Agora-RTC

11 stars 16 forks source link

Server side rendering issue #32

Open mrparmar opened 3 years ago

mrparmar commented 3 years ago

I am struggling create a angular 9 SSR (Server side rendering) build. I am getting this error.

ReferenceError: window is not defined

at Object../node_modules/agora-rtc-sdk/AgoraRTCSDK.min.js (D:\Mayur\Gainbuzz Projects\brytoattendeesweb\dist\brytoattendeesweb\server\main.js:165207:52)
    at __webpack_require__ (D:\Mayur\Gainbuzz Projects\brytoattendeesweb\dist\brytoattendeesweb\server\main.js:20:30)
    at Module../node_modules/angular-agora-rtc/__ivy_ngcc__/fesm2015/angular-agora-rtc.js (D:\Mayur\Gainbuzz Projects\brytoattendeesweb\dist\brytoattendeesweb\ser
ver\main.js:165228:71)
    at __webpack_require__ (D:\Mayur\Gainbuzz Projects\brytoattendeesweb\dist\brytoattendeesweb\server\main.js:20:30)
    at Object../src/app/app.module.ts (D:\Mayur\Gainbuzz Projects\brytoattendeesweb\dist\brytoattendeesweb\server\main.js:266686:29)
    at __webpack_require__ (D:\Mayur\Gainbuzz Projects\brytoattendeesweb\dist\brytoattendeesweb\server\main.js:20:30)
    at Object../src/app/app.server.module.ts (D:\Mayur\Gainbuzz Proje
cts\brytoattendeesweb\dist\brytoattendeesweb\server\main.js:266780:22)
    at __webpack_require__ (D:\Mayur\Gainbuzz Projects\brytoattendeesweb\dist\brytoattendeesweb\server\main.js:20:30)
    at Object../src/main.server.ts (D:\Mayur\Gainbuzz Projects\brytoattendeesweb\dist\brytoattendeesweb\server\main.js:289021:27)
    at __webpack_require__ (D:\Mayur\Gainbuzz Projects\brytoattendee
sweb\dist\brytoattendeesweb\server\main.js:20:30)

A server error has occurred.
node exited with 1 code.
connect ECONNREFUSED 127.0.0.1:51662
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! brytoattendeesweb@0.0.0 dev:ssr: `ng run brytoattendeesweb:serve-ssr`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the brytoattendeesweb@0.0.0 dev:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Lenovo\AppData\Roaming\npm-cache\_logs\2020-11-23T12_33_27_197Z-debug.log
plutoless commented 3 years ago

@mrparmar server side rendering env will not have window. if you would like to use server side rendering, you will need to include our sdk in script tag instead of compile time.

mrparmar commented 3 years ago

@plutoless Thanks for reply us. Can you plz share demo example?

plutoless commented 3 years ago

@mrparmar a simple example would be include our websdk in in your server rendering template html. you can also include Githubissues.

  • Githubissues is a development platform for aggregating issues.