File API Routes Not Working?
Followed the instructions in the docs to setup a demo project. Added files for API routes and the code autogenerated as expected! However, I keep getting Not Found when I hit the routes in the browser. Am I missing a step?
10 Replies
vicious-gold•9mo ago
can you please provide a minimal example?
e.g. via a github repo
wise-white•9mo ago
have you restarted the dev server ?
i had to delete my generated file and restart the dev server for it to work the first time
sunny-greenOP•9mo ago
GitHub
GitHub - MassHesteria/tanstack-start-demo: Trying out Tanstack Star...
Trying out Tanstack Start Beta release. Contribute to MassHesteria/tanstack-start-demo development by creating an account on GitHub.
sunny-greenOP•9mo ago
Definitely have restarted the server, maybe I broke something adding Tailwind. I could try starting over if that's the best approach
I just added a
api.stuff.ts
file in /routes/
thinking I'd get a /api/stuff
routeforeign-sapphire•9mo ago
@MassHesteria I believe you need an app/api.ts file: https://tanstack.com/router/latest/docs/framework/react/start/api-routes#setting-up-the-entry-handler
API Routes | TanStack Router React Docs
API Routes are a powerful feature of TanStack Start that allow you to create server-side endpoints in your application without the need for a separate server. API Routes are useful for handling form s...
sunny-greenOP•9mo ago
Yep, that seems to be the difference maker! Thanks!
noble-gold•9mo ago
Hey I have bootstrapped a new project with the CLI, and i do not have the app folder, do I need to create the api entry point?
foreign-sapphire•9mo ago
If you plan on using API routes, probably yes
noble-gold•9mo ago
I do not have the app folder
where should I create it
foreign-sapphire•9mo ago
I am unsure if the CLI is final yet, so I'd follow this: https://tanstack.com/router/latest/docs/framework/react/start/build-from-scratch
Build a Project from Scratch | TanStack Router React Docs
[!NOTE] If you chose to quick start with an example or cloned project, you can skip this guide and move on to the guide. So you want to build a TanStack Start project from scratch? This guide will hel...