App router API routes not found (even though logs say they're compiled)
Unanswered
Cuban Crocodile posted this in #help-forum
Cuban CrocodileOP
So i'm having this very annoying problem where i see my endpoints being compiled, but the moment my browser/client tries to send a request i get a 404 not found. I have tried to put a global
console.log()
in the route.ts
files but nothing is being printed. What's even weirder is that the problem seems to randomly appear and go away again (during development) even if i don't change the API code at all. It has worked before for hours without problems. I am using the default folder structure for API endpints in the App Router as described in the Next.js docs. The problem is not limited to the endpoint shown in the screenshot, other endpoints have experienced the same issue. ChatGPT tells me it's an internal dev server bug in Next.js and that it fails to register the route handler.1 Reply
Black carpenter ant
the dev server in next kinda just gives up on registering the route sometimes, and then pretends it never existed. no logs, no handler hits, just straight up 404.
for me, killing the server and restarting, deleting the .next folder, and restarting usually fixed it...
i also noticed it happens more often when i move files around or rename stuff. might help to check if the route is actually being picked up by restarting from a cold start.
tbh if chatgpt told you it’s a dev server bug, it’s probably right. not saying it's comforting, but at least we’re not alone in the chaos lol.
for me, killing the server and restarting, deleting the .next folder, and restarting usually fixed it...
i also noticed it happens more often when i move files around or rename stuff. might help to check if the route is actually being picked up by restarting from a cold start.
tbh if chatgpt told you it’s a dev server bug, it’s probably right. not saying it's comforting, but at least we’re not alone in the chaos lol.