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.


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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 ?