I have generated a LoopBack
project and Angular4
project using angular-cli
.
My LoopBack project serves html files at port 3000
and my Angular4 project is being served at 4200
.
Now I need to know if I can serve this angular app on 3000 just like serving static files from LoopBack directory?
What I am trying to ask is if it is possible to use LoopBack server to serve Angular4 app just like it serves Angularjs app?
Thanks
I'm assuming you're asking about a production environment. My current Angular setup includes ui-router with
html5Mode
enabled, so to have Loopback serve static content (and avoiding to introduce an Nginx instance or something similar to do so) I had to remove the static middleware frommiddleware.json
(everything under"loopback#static"
key) and make loopback selectively pass through requests to its Api or respond with the corresponding file, inserver/server.js
and assuming my client was built inclient-dist
under project's root:If you don't want to use
html5Mode
, just makeloopback#static
point to the directory where your client was built, just as described in https://loopback.io/doc/en/lb3/Add-a-static-web-page.html .For my development environment I just tell the Loopback SDK to use
localhost:3000
: