You log in through the proxy, and the app sends you to http://localhost:3000/dashboard, which does not exist from outside. The backend thinks it lives on its own port. nginx can rewrite that header on the way out.
location /app/ {
proxy_pass http://127.0.0.1:8081/;
proxy_redirect http://localhost:3000/ /app/;
}
When the backend answers with a Location or Refresh header that starts with the first value, nginx replaces that part with the second. A redirect to http://localhost:3000/dashboard comes out pointing at /app/dashboard on the proxy’s own host name.
nginx already does this for the address in proxy_pass itself. A redirect to http://127.0.0.1:8081/home was fixed without any extra line, because that is the default setting. You only need your own line when the app builds redirects from another name, like a localhost:3000 from its config. You can list several proxy_redirect lines for different patterns.
This only touches headers. Links inside the HTML or a redirect done with JavaScript still point to the wrong place, and for those the real fix is the app’s base URL setting, often together with proxy_set_header Host $host and X-Forwarded-Proto. I’d look for that setting first and keep proxy_redirect for apps that have none. proxy_redirect off turns the rewriting off completely.
Further reading: proxy_redirect
Going deeper: Guide: fix a 502 Bad Gateway in Nginx Proxy Manager, with a checklist that finds the cause