How to serve angular using Django server? I don't want to host two different server for angular and Django. How to do it with a single django server? I have developed frontend application using angular 6 and backend using DRF. I am running django server in the back end and using ng serve command to run angular application.
0
votes
Write the docker file for django and angular and use it. Use webapack to build and integrate with django and run it.
- Seenu S
How you want to deploy your Django app? using gunicorn + nginx? If yes then you can use that nginx to serve your Angular project
- Toan Quoc Ho
@Ton quoc Ho. How to serve angular using nginx?
- user8106849
Just build your angular app into a bundled version. Then on nginx, using reverse proxy to route requests to your django app on path /api/, then route / to index.html (which created by Angular build). Here is an example gist.github.com/lciolecki/a82c4e5f250bfa5c7d63d1b7f65d5a0c
- Toan Quoc Ho
1 Answers
1
votes
To achieve this, you should serve your Angular project in production mode. This is a must have if you seriously deploy your project to the world, Angular will optimize the bundle to make UX better than on development mode.
And also for Django project, you should deploy it using gunicorn or uwsgi and using nginx as a reverse proxy (reference this gist) for your application.
Hope that helps!