我已经做了什么
- I have a frontend entirely built with React.JS.
- All the business logic is handled by Django and exposed by Django REST Framework via an API.
- I'm able to build for different mobile environnements (Android and iOS via Cordova)
- The web application is accessible via my Django project (the same that exposes the api), the frontend is sill the same ReactJS code bundled via webpack.
The App has a single entry point, main.js which is a bundled version of my react.js components and dependencies, so my index.html typically looks like this :
<body> <script type="text/javascript" src="/static/bundles/main-3997ad3476694c3c91cf.js"></script> </body>
我想要做什么
- 我想提供一个服务器端渲染我的Web应用程序,让Web爬虫正确地索引我的应用程序(我不需要为移动构建进行服务器端渲染)。
考虑到我的应用程序是单页应用程序,我该如何处理?我不想重复造轮子或复制代码。为了实现这种自动服务器端呈现,我必须编写哪种node.js服务器?是否有任何方法可以直接在Django中提供服务器端呈现(通过一些工具读取和解释客户端显示的页面的最终结果,并返回此原始HTML)?