Question

nodejs, Express Cannot GET //v1 error

I have an app running on node.js. It works locally on my pc but when i upload to my server with do i keep getting this annoying error message: “Cannot GET //v1/foodtruck”

Can someone please assist me to resolve this issue.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

The problem will be with your nginx config, although the syntax will pass and the base route will work, for any other route within this, you have to set up your nginx as /v1/, you have to include the extra / after for example,

    proxy_pass http://localhost:3010;
    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;
}```

Should actually be written as:

```location /v1/ {
    proxy_pass http://localhost:3010;
    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;
}```

 A slight difference, but it will forward all request to other routes correctly, and wont give the //v1 error, hope this helps you or anyone viewing this.

how do you run your NodeJS Express APP? Do you use pm2 ?