T
TanStack3mo ago
quickest-silver

Using router in a dynamic subpath, recieving page not found

I'm trying to host a static app on either/ & /subpath I've tried all combinations of setting the basePath on the router & in vite to "", "./" & "/" , the app does load however we first hit a page not found , navigating to / works from within the app but / should be /subpath Express
// env.BASE_PATH is either / or /subpath
app.use(env.BASE_PATH, express.static("./serve"));
app.use(`${env.BASE_PATH}{*splat}`, (_req:Request, res: response) => {
response.sendFile("./serve/index.html")
});
// env.BASE_PATH is either / or /subpath
app.use(env.BASE_PATH, express.static("./serve"));
app.use(`${env.BASE_PATH}{*splat}`, (_req:Request, res: response) => {
response.sendFile("./serve/index.html")
});
Vite
export default defineProject({
base: "./" // Also tried "", "/" in combination with the router & separately
...
});
export default defineProject({
base: "./" // Also tried "", "/" in combination with the router & separately
...
});
Router
const router = createRouter({
basepath: "", // Also tried "./", "/" in combination with vite & separately
...
});
const router = createRouter({
basepath: "", // Also tried "./", "/" in combination with vite & separately
...
});
Any help is appreciated, i dont want to hardcode the subpath into the router if i can avoid it!
3 Replies
notable-maroon
notable-maroon3mo ago
can you please create a github issue with a complete example repo?
quickest-silver
quickest-silverOP3mo ago
GitHub
GitHub - JoshHiles/JoshHiles-tanstack-router-dynamic-subpath
Contribute to JoshHiles/JoshHiles-tanstack-router-dynamic-subpath development by creating an account on GitHub.
quickest-silver
quickest-silverOP3mo ago
Should just be able to clone & run pnpm install & then pnpm run dev to build and run the express server Apologies for the rush job, any issues give me a shout

Did you find this page helpful?