I have a React application that I need to deploy, and I am considering two options for serving the production build:
1. Serving the React build directly with Django (e.g., using WhiteNoise or serving it as static files).
2. Using a Node.js server (such as Express) to serve the React build separately.
I am having a websocket server in django channels using asgi. But I have build a react app in using the react. As the SSR is better in performance I was wondering if whether I can serve my react build with django or not.
Which approach is generally recommended, and what are the pros and cons of each?
I have a React application that I need to deploy, and I am considering two options for serving the production build:
1. Serving the React build directly with Django (e.g., using WhiteNoise or serving it as static files).
2. Using a Node.js server (such as Express) to serve the React build separately.
I am having a websocket server in django channels using asgi. But I have build a react app in using the react. As the SSR is better in performance I was wondering if whether I can serve my react build with django or not.
Which approach is generally recommended, and what are the pros and cons of each?
Share Improve this question edited Mar 23 at 7:48 Yuvraj asked Mar 22 at 21:03 YuvrajYuvraj 1 1- Are you asking pros and cons of Django vs Express for websockets? This isn't really a good question for Stack Overflow. Use whichever you're most comfortable with. – pguardiario Commented Mar 23 at 1:36
1 Answer
Reset to default 0If you have server-side components then absolutely you will need to a node.js server (which will do the rendering of react server-side components).
The case where you can use static files serving using Whitenoise or nginx, apache.. or something similar is when you have only one bundle file (or many) of your react app that was built and generated once every new deployment (each version) and in this case your react app is only client-side rendering.
The most important thing in your case is to have a single point of enterance, like you can direct all requests to django server and the django server will communicate with node.js server, or similarly, you can have nginx server which redirects some prefixes to the node.js server.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744303562a4567619.html
评论列表(0条)