How to use Traefik PathPrefix on an Nginx Docker image?
I think what you're missing is that you need to let React know that it is not hosted at the root /
but a sub-path. In order to configure a different path and thus enabling React to properly build the paths to also access the assets such as CSS and JS, you need to set the "homepage"
key in your package.json
to a different value, for example,
"homepage": "http://address/app",
You can read more on the topic in the deployment section of the React docs.
This is an interesting problem we had a couple days ago as well. I'll share what I found in the hopes that it points you in some form of right direction.
Using PathPrefix only, the application has to fully listen on the prefix.From https://docs.traefik.io/routing/routers/#rule
Since the path is forwarded as-is, your service is expected to listen on /products.
There is a Middleware that strips out prefixes should your app not listen on the subpath:https://docs.traefik.io/middlewares/stripprefix/However the caveat there is
If your backend is serving assets (e.g., images or Javascript files), chances are it must return properly constructed relative URLs.
We haven't quite found solutions yet, other than changing the paths in our applications. But maaaybe this helps