What version exactly? It matters. Run caddy version to see the exact version number.
If you use route, it overrides the predetermined directive sorting order. In this case, this will mess things up, because try_files depends on root being set before it, so that it knows where to look for files on disk.
In this case, you don’t need route at all, because rewrite is already ordered before try_files. Do this instead:
I assume you have a ./client/dist/ted/ directory. Having try_files fallback to /ted/ is important, because otherwise it would serve the index.html in ./client/dist/ instead of the one in ./client/dist/ted/.
I have tried without the route block as well. The thing is that /ted is not a physical route. ted is a route parameter that decides what to load on that page.
the rewrite does not happen. It is loading the index file in all scenarios and not rewriting to /tenant.
I have moved to a subdomain based approach instead of a route based approach for now, where I am simply routing the domain to the same root and doing the tenant resolution at an app level. But I would like to understand how something like this would work.
The way file_server works is by taking the defined root, then appending the current request path to it, and looking for a file on disk at that location.
The try_files directive, similarly, will rewrite to the first matching root + argument. So if none of them match, no rewrite will happen. So if there’s no ./client/dist/ted/ at least, then no rewrite happens.