Node.js can';t使用ngnix代理通行证访问快速子路由

Node.js can';t使用ngnix代理通行证访问快速子路由,node.js,express,nginx,Node.js,Express,Nginx,我正在ec2上部署一个MERN stack应用程序,我遇到了无法访问子路由的问题 server.js const app = express(); app.use(bodyParser.json()) app.use(express.json()) app.use(cors()); app.options('*', cors()); app.use((err, req, res, next) => { res.status(400).send({httpStatus:400, r

我正在ec2上部署一个MERN stack应用程序,我遇到了无法访问子路由的问题

server.js

const app = express();

app.use(bodyParser.json())

app.use(express.json())
app.use(cors());
app.options('*', cors()); 


app.use((err, req, res, next) => {
res.status(400).send({httpStatus:400, response: "Invalid Request. Only valid json requests accepted."})
});

app.get('/api',(req,res) => res.send("hello world"))
app.post('/api/users/create',(req,res) => console.log("creating user..."))
app.listen(5000,'localhost',() => console.log('listening on 5000'))
nginx配置文件:

server {
listen 80;
 #server_name your_domain.com;
  location / {
      # This would be the directory where your React app's static files are stored at
       root /my-app/client/build/;
       try_files $uri /index.html;
  }
  location /api/ {

   proxy_pass http://localhost:5000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;

 }
}


静态文件和单个路由可以工作,但带有子例程的路由不工作..请求超时。有什么帮助吗?

您永远不会结束请求,这就是请求超时的原因

app.post('/api/users/create',(req,res) => {
  console.log("creating user...");
  res.send('created');
})