The documentation (https://angular.dev/guide/ssr) states that:
Angular CLI will scaffold an initial server implementation focused on server-side rendering your Angular application. This server can be extended to support other features such as API routes, redirects, static assets, and more. See Express documentation for more details.
And this is fine, but when you run angular (ng serve
) the server (server.ts
) is not even used so none of our API routes are registered.
What is the recommended approach here? Should we spin our own express.js server for API routes in development?
use
npm run watch
instead ofng serve
. (It does not open the default port 4200). after that you need to runnpm run serve:ssr:<project_name>
. The project will run on server port http://localhost:4000 But it does not make auto reload. For the time being I found this solution to run server.ts.