I am using Expressjs as the backend for my Angular2 application. Both projects are in the same directory structure:
/index.html <-- Angular index file
/app.js <-- Expressjs
/package.json
/Gruntfile.js
/bin <-- Expressjs bin
/routes
/public <-- Angular directory
/bin <-- Angular bin
/main.ts
/app.component.ts
...
In my .json package, I have this script that runs both Angular2 and Expressjs
"start": "grunt & node ./bin/www & concurrently \"npm run tsc:w\" \"npm run lite\" "
This will start as expected, but on different ports. I am wondering if this is the best solution. In some cases, I would like to access / users /: id on Expressjs (when making calls from Angular), and in some cases I would like to access / users /: id on Angular for a regular user.
Should I run Express and Angular on different ports or is there a better way to do this, i.e. all express routes in / api? In this case, how do I configure this? Using different ports is what is done by default.