'Routing error with nginx when deploying app

This must be very common knowledge I can't seem to get. I don't even know the keywords to explain this. I'll use what I understand till now. So here is the situation I'm in,

localhost:5000 ('/') takes to a base page. I set localhost/api as location in nginx to the same port. So going to localhost/api is the same thing as going to localhost:5000.

Now as usual, some UI is there with some text box and different buttons. Normally, form-action for some button goes to ('/run') endpoint and the process continues. But after setting nginx, I expected this localhost/api/run in url box of browser but got localhost/run instead. This is the issue.

Here what I added to /etc/nginx/sites-available/default

 location /api {
                proxy_pass http://127.0.0.1:5000/;
        }

I must tell you I know little to nothing about nginx (you already got that I guess). I just know what it is use for. I'd really appreciate a quick and general solution to this, and if someone could direct me to a playground for learning nginx would be wonderfull.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source