Redirecting /api to homepage
Hey! I'm using TS Router (via Start) and am trying to redirect
/api to the homepage. I made a routes/api/index.ts that redirects to /, but it doesn't seem to ever get hit. How can I fix this?11 Replies
harsh-harlequin•8mo ago
how do you redirect?
wise-whiteOP•8mo ago
harsh-harlequin•8mo ago
not a bug really
just not supported right now
however, your way should work
can you provide a complete minimal example repo?
wise-whiteOP•8mo ago
Here's my full redirect code:
Give me a few minutes whilst I make the example repo
wise-whiteOP•8mo ago
GitHub
GitHub - SkyfallWasTaken/tanstack-start-redirect-api-route
Contribute to SkyfallWasTaken/tanstack-start-redirect-api-route development by creating an account on GitHub.
harsh-harlequin•8mo ago
hm seems like a bug in the api routes matching
since we are currently reworking API routes and they wont be bound to the /api prefix any more, this will be resolved once we have released that
wise-whiteOP•8mo ago
got it! should I file an issue?
harsh-harlequin•8mo ago
it shouldnt be necessary
wise-whiteOP•8mo ago
👍
in the meantime, is it possible to mount hono or some other API framework by any chance?
harsh-harlequin•8mo ago
wise-whiteOP•8mo ago
nice! thank you :)
For future searchers, if you set
src/api.ts to:
You can then use the api directory for your routes instead of server/api or some other directory!