Changing base path does not seem to work for ingress
Hi
I've been tearing my hair out for a while on this issue. We basically have multiple apps on a single domain:
customer.company.com/app-a
, customer.company.com/app-b
, customer.company.com/app-c
. We use ingress to manage routing when users visit specific domain/folder combinations.
However, there seems to be an issue where I can't figure out how to tell TanStack Start to understand this setup:
1. Setting router basepath
to /app-a
means that when you visit customer.company.com/app-a
, Start runs into an infinite redirect loop, unless you go to customer.company.com/app-a/app-a
- then it loads the page but not the assets, since the assets request customer.company.com/app-a/assets
when they should be requesting customer.company.com/app-a/app-a/assets
.
2. Setting both router basepath
and Vite base
has similar outcomes.
3. Setting only Vite base
causes it to append app-a
to URLs instead of realizing we're already in that folder.
I've tried all kinds of combinations at this point, and it's a shame because I love TanStack Start and want to use it wherever we need it. But this has been such a problem that we have to create separate domains like app-a.customer.company.com
to work around it.
If anyone has any ideas on what I can do differently or some magic solution, please share. Thank you!3 Replies
afraid-scarlet•3w ago
can you please create a github issue including a complete example project that reproduces this issue?
wise-whiteOP•3w ago
Hmm that would require to setup an ingress example, ill find some time today/tomorrow
Ill try explain whats happening here a bit better, setting up this on a repo would require a domain for an example but basically, we have this ingress:
- path: /public(/|$)(.*)
pathType: Prefix
backend:
service:
name: frontend-public
port:
number: 80
Where we have a domain like
customer.company.com
and when someone hits that they will be redirect to any number of services.
One of these services is a tanstack start app, but for what ever reason tanstack start is not recognizing that we are on a folder /public in this example and so it routes all traffic through / rather then /public.
so user hits customer.company.com/public - tanstack start app
for some reason when setting the basepath the server itself does not respect the path, its almost like its doubling the path as I can access assets through customer.company.com/public/public/asset258235.js
Where I would expect the sever to understand that we are in a folder and that it should be serving /public/asset.js not /public/public/asset.js
Tanstack router by itself works very well and so we've been force to switch to that for now, setting the basepath and serving the content through nginx is working very well. But with this tanstack start node server it just breaks
This is a annotations on the ingress itself to set capture group and how/what will be forwardred
nginx.ingress.kubernetes.io/rewrite-target: /$2
docs here: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#rewriteafraid-scarlet•3w ago
cant this be reproduced outside of your setup?
just with a simple start example that runs locally?