I have an app on azure devops with .net core and angular. Now, I want to implement Angular Universal SSR.
Then, I did on my project:
ng add @nguniversal/express-engine --clientProject angular.io-example
My package.json is:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "npm run build:client-and-server-bundles && npm run compile:server",
"build:ssr": "npm run build:client-and-server-bundles && npm run compile:server",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"bundle-report": "ng build --extract-css --stats-json && webpack-bundle-analyzer dist/stats.json",
"compile:server": "webpack --config webpack.server.config.js --progress --colors",
"serve:ssr": "node dist/server",
"build:client-and-server-bundles": "ng build --extract-css --prod && ng run Catevering:server:production"
}
Then, I can see on kudu the next structure files:
- server
- browser
- server.js
[Check here my file structure][1]
Finally, I change the next line on my startup.cs file:
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});
By:
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist/browser";
});
This way works on and my app is working. But, my app is not working as SSR. In my localhost my app works as SSR with the next command:
node server.js
For that, I tried to change my code like this:
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist/server.js";
});
But this is not working. However, my backend web api is working.
Someone can help me?
I need to run my app as SSR on azure devops.