In my case, I just want to use payment API that's why I render angular app from the node.js to combine and run both apps with APIs on the same port in shared hosting was + point for this scenario.
SSR is beneficial Because the code compiles in the server, this is a win for low-performing devices. Servers can do all the hard work so that your userβs devices donβt have to.
In this case it seems that you are only serving Angular app as static content from your express server. It doesn't seem like you are doing any SSR here. If SSR was working, you would still get rendered page when JS is disabled on the browser. I don't think it will work in your case.
Executing app.set('view engine', 'pug'); just means that express will process pug templates. Angular doesn't use pug templates.
You need to use @nguniversal/express-engine for doing Angular SSR.
Yes, Tomas, you are right, but I have a front-end angular app with Angular material UI, I want to consume Payment API only for that purpose I need backend (Node.js). I thought to run the angular app on the express server on the same port.
that's why I followed this approach.
Do you have any other best solution/suggestion?
Another solution could be to use CORS middleware on the backend side and to just serve Angular app with nginx or some other fast http server. Both approaches have their pros and cons.
In my case, I just want to use payment API that's why I render angular app from the node.js to combine and run both apps with APIs on the same port in shared hosting was + point for this scenario.
SSR is beneficial Because the code compiles in the server, this is a win for low-performing devices. Servers can do all the hard work so that your userβs devices donβt have to.
In this case it seems that you are only serving Angular app as static content from your express server. It doesn't seem like you are doing any SSR here. If SSR was working, you would still get rendered page when JS is disabled on the browser. I don't think it will work in your case.
Executing
app.set('view engine', 'pug');
just means that express will process pug templates. Angular doesn't use pug templates.You need to use @nguniversal/express-engine for doing Angular SSR.
Yes, Tomas, you are right, but I have a front-end angular app with Angular material UI, I want to consume Payment API only for that purpose I need backend (Node.js). I thought to run the angular app on the express server on the same port.
that's why I followed this approach.
Do you have any other best solution/suggestion?
Another solution could be to use CORS middleware on the backend side and to just serve Angular app with nginx or some other fast http server. Both approaches have their pros and cons.
yes, sure thanks for your discussion and feedback :-)
@tomas Happy coding