Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django + Angular deployment on Heroku

I have a project consisting of the Django Rest Backend and AngularJS frontend. The project root directory contains two folders: backend and frontend, in the first one there is placed the whole Django app and in the second one the Angular frontend app.

Is it possible to deploy such a structure to Heroku in one subdomain. To be precise, I want to have urls like this:

myapp.heroku.com - which will load the whole Angular project frontend myapp.heroku.com/backend - which will be the Rest API endpoint

How to deploy both apps on Heroku to obtain such a solution? Or maybe you have any other suggestions concerning the project structure and deployment?

like image 393
Marcin Avatar asked Sep 29 '22 21:09

Marcin


2 Answers

Have a look at this project.

https://github.com/djng/djng

They've used a DjangoREST backend and a Angular Front end. Instead of letting heroku autodetect the app environment, they've managed to make a heroku app using 'Buildpacks' where, you specify that the project has multiple builds (heroku-buildpack-multi), then specify the python based buildpack and the angular based (grunt) buildpack.

like image 80
Arun kumar Gandlur Avatar answered Oct 11 '22 11:10

Arun kumar Gandlur


There's nothing particularly special about this setup. Angular code is just static files, and can be served from whatever point you want; then the Ajax calls to the REST backend go to the endpoint you determined.

like image 1
Daniel Roseman Avatar answered Oct 11 '22 09:10

Daniel Roseman