OK - this is an old issue (https://github.com/matomo-org/matomo/issues/11765), but here it is again.
I believe the other bug was fixed, and my own experience is that the issue went away. Is this a new occurrence of the same bug?
it wasn't fixed (it never went away.) I gave up on bugging for it...
We are experiencing a similar issue. We have a docker cluster, Using varnish/apache with matomo in a subdirectory /analytics/ route. We have set the HTTP_X_FORWARDED_URI and the proxy_uri_header=1 and we can see some urls have rewritten. However some assets do not get rewritten.
We since realised that the obvious default behaviour of the browser is to make calls to the url base (not including the directory) unless there is an extra / at the end of our base url/directory/ in the varnish config so that the browser knows its a directory and not a file.
On top of following the steps in the above FAQ, try adding a / to the end of your directory wherever you have configured the base route to matomo either in varnish or apache.