mikr13
(mikr13)
December 22, 2024, 7:25am
1
Summary
I have a POST:/api/github
route in my next.js app.
Path to file: src/app/api/github/route.ts
When I try calling the API from postman, it returns 404 error, when I open up browser to just check in case, that also returns 404 error. I also don’t have any conflicting paths in app router
PFA the screenshots for more details:
Directory ss:
Ngrok API Response ss:
Next.js logs:
Code SS:
Please help. Thanks!
Additional information
"next": "15.1.2",
"react": "^19.0.0",
middleware.ts code:
export const config: MiddlewareConfig = {
matcher: [
"/login",
"/logout",
"/api/:path*",
"/dashboard/:path*",
"/user/:path*",
],
};
system
(system)
December 22, 2024, 7:25am
2
There’s another community post with 404 debugging tips that might be helpful. Please give these solutions a try and let us know how it goes.
Sometimes things don’t go as expected when deploying a website. If you see a 404 on your site, that means the page or resource couldn’t be found.
There are many possible causes, and the absence of something can be tricky debug if you don’t know where to look. Here are some things you can do to find the cause and fix it.
Debugging Tips
Check the error code
If you see a mostly white screen with 404: NOT_FOUND along with a Code and and ID then you can click the blue info box below the error deta…
A human should be around soon to offer more advice. But you can also get helpful information quickly by asking v0 .
mikr13
(mikr13)
December 23, 2024, 7:56am
3
I noticed something, so when I have some logic inside my route handler, it goes 404, but when I do something like:
import type { NextApiRequest } from 'next';
export async function POST(
req: NextApiRequest,
) {
return Response.json({ message: 'Hello from Next.js!' })
}
Then it works fine. Not sure what this behaviour is though.