0

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.

4
  • Write the docker file for django and angular and use it. Use webapack to build and integrate with django and run it. Commented Sep 18, 2019 at 15:05
  • How you want to deploy your Django app? using gunicorn + nginx? If yes then you can use that nginx to serve your Angular project Commented Sep 18, 2019 at 15:08
  • @Ton quoc Ho. How to serve angular using nginx? Commented Sep 18, 2019 at 15:19
  • 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 Commented Sep 18, 2019 at 16:01

1 Answer 1

1

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.