React and Django

I am running django on port 8000 and react on port 3000

i want to run both on a single port and how should i do it when i deployed project i used all the methods and suggest me something different for this question in detailed format

and react on port 3000

No, react does not require any port. What you did was run the react development server that is used to just conveniently show your react app.

When the react app is in a deployable state, what you do is converting the react app you made with npm run build this will convert the app in a few static HTML, JavaScript and CSS files.

These static files are then servered by a webserver like nginx for example. While the Django app often runs on port 8000, or a socket file, you typically don't directly expose that to the outside world either: you let nginx or another web server forward the requests to the Django server, and typically you use gunicorn for example to spawn multiple Django processes such that you can process multiple requests concurrently.

Вернуться на верх