I have created angular 4 app and I can run it using ng serve --open
and it runs on localhost:4200
,
what I want is I have also created api using nodejs
in same angular project now I want to run that API at localhost:4200/api
so I have tried something like this
my angular 4 and nodejs srtucture look like this
/dist
/server
/routes
/server
/src
app.js
package.json
in app.js I used
app.use(express.static(path.join(__dirname, 'dist')));
app.use('/app/api', apiRoutes);
const port = process.env.PORT || '3000';
server.listen(port, () => console.log(`API running on localhost:${port}`));
Once I run using nodemon app.js
and go at localhost:3000
it run my angular app and it's fine and than I go at localhost:3000/app/api
it's also work fine and good ,
But when I change in angular app it's not auto refresh my app because it's running node app currently for refresh it I need to run ng build
and than it will effect my new changes on angular app
So, What I want is to run ng serve --open
it will run angular app but not node js api so want to run both and once i change in any from angular app or node js app it must be auto refresh.