嗨,我正在尝试在 digital ocean apache 服务器中托管 React 和 django 应用程序。当我成功做到这一点时,我得到了 Django Rest Framework 的屏幕作为 Droplet IP 地址的页面。我尝试了很多东西,但找不到答案。有人可以告诉我如何在数字海洋或 namecheap 共享托管中正确托管 django React 应用程序
提前致谢。
这里是一个关于如何使用 nginx 实现它的示例。
upstream django {
server app:8000;
}
server {
listen 80;
# base url to django apis
location /api/ {
proxy_pass http://django/api/;
}
# path for react build
location / {
autoindex on;
alias path_to_react_build;
try_files $uri /index.html;
}
}