#Angular SSE ReferenceError: EventSource is not defined
16 messages · Page 1 of 1 (latest)
Given the stack trace, I guess you enabled SSR on this application, and you're executing this code on the server. I don't think it makes much sense to do that on the server. And apparently, node doesn't support it anyway.
Besides, calling getData() from the constructor on the service and not subscribing to the observable it returns doesn't seem correct either.
I havent enabled SSR (server-side rendering) this is basically a new generated angular project
I start it with npm start from my pc
I have also done this. But it doesnt help to get rid of the error
Show us the content of your angular.json file. Or tell us what you find under the distdirectory when executing ng build.
See:
"server": "src/main.server.ts",
"prerender": true,
"ssr": {
"entry": "server.ts"
}
and the fact that you have a server directory under dist mean that you have enabled ssr in your project.
Didn't know i have ssr by default. removing
"ssr": { "entry": "server.ts" }
did the trick, thanks
Accually no, it just poped up again 😦
I have done some research and Angular 17 has SSR by default. What do you recommend for a communicartion between my python script and my angular 17?
Websockets?
No, it doesn't. It asks you whether you want to enable SSR or not, and the default answer is No:
Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? (y/N)
To communicate between a web client and a server, the usual solution is to use HTTP. Use websocket if you need bidirectional full-duplex communication, but that's usually not the case. I'm not sure what this question has to do with SSR though.
i havent added SSR by myself. I did ng new <appname>. But thats not important. I dont really need SSR since the website will be run only locally.
Re-run ng new for another project, and pay attention to the question it asks. What I pasted is one of the questions it asks.