You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a "regular" React + Vite + TanStack Router app. To generate relative paths, my Vite app has the configuration base: './'. The TanStack Router itself has no specific configuration.
When I run the app in the root directory of a web server, everything works fine. However, when I deploy it to a subdirectory like /company/tool on an Apache server, the app loads, but the TanStack Router shows a 404 error, saying the page cannot be found.
Can anyone tell me how to configure the router so it works for all subdirectories?
Edit: It works with const router = createRouter({ routeTree, basepath: "/company/tool" }); but this looks bad I guess? Because now I always have to deploy the app under this base path...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I have a "regular" React + Vite + TanStack Router app. To generate relative paths, my Vite app has the configuration base: './'. The TanStack Router itself has no specific configuration.
When I run the app in the root directory of a web server, everything works fine. However, when I deploy it to a subdirectory like /company/tool on an Apache server, the app loads, but the TanStack Router shows a 404 error, saying the page cannot be found.
I assume I need to set the correct base path ( https://tanstack.com/router/v1/docs/framework/react/api/router/RouterOptionsType#basepath-property ), but I have tried several options, and none seem to work.
Here is a sandbox: https://stackblitz.com/edit/vitejs-vite-cakytccn. You can also test this locally. I have also set up a Docker Compose configuration with an Apache server :slight_smile:
Can anyone tell me how to configure the router so it works for all subdirectories?
Edit: It works with
const router = createRouter({ routeTree, basepath: "/company/tool" });
but this looks bad I guess? Because now I always have to deploy the app under this base path...Beta Was this translation helpful? Give feedback.
All reactions