Can I deploy Angular app created with Angular-CLI to Heroku without an (additional?) server part?

  angular, angular-cli, heroku, node.js

I am new to Heroku. I would like to test it with a freshly created Angular app made with the angular-cli (ng new my-app).

In my local environment I am able to do ng serve and see my application running in my browser at localhost:4200.

I would like to be able to see my app on the domain provided by Heroku without modifying my app too much. Right now, when trying to access my Heroku app, I am stuck with " Application error".

Looking for "Angular" and "Heroku" I often see that people use a backend to serve the application (e.g. express). Do I really need one or is there a way to avoid that if possible?

I am asking this because I’d like to test the Instagram API and I really don’t need a backend for this (at least, I guess a backend is already embedded in the app I created otherwise how can it run on port 4200?).

I guess I should somehow install all the dependencies on Heroku, and I already tried to modify my package.json in many ways without much success (I’d better not show what I did otherwise it might get confusing).

I hope this all makes sense, if I need to add a server part I will do it, but I’d like to know if I have to.

This is my local environment:

node -v
v13.11.0

npm -v
6.13.7

ng version
Angular CLI: 10.0.8
Node: 13.11.0
OS: linux x64

Angular: 10.0.14

Source: Angular Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.