设置 react fronted + node express 作为后端 - 405

设置 react fronted + node express 作为后端 - 405

我的项目结构为

/var/www/html/server.js - express node api
/var/www/html/client/build/ - react npm run build
/var/www/html/client/package.json and other files

我的 nginx 配置

server {
    server_name myEC2ip;

    location / {
        root /var/www/html/client/build/;
        try_files $uri /index.html;
    }

   location /var/www/html/ {
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header Host $http_host;
       proxy_set_header X-NginX-Proxy true;
       proxy_http_version 1.1;
       proxy_pass http://myEc2IP:5000;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection 'upgrade';
       proxy_set_header Host $host;
       proxy_cache_bypass $http_upgrade;
   }
}

我收到 405 错误 - 哪里出了问题?

相关内容