Simple question about /api/posts/
Answered
Rhinelander posted this in #help-forum
RhinelanderOP
What is difference between /api/posts/route.js vs /api/posts/posts.js
7 Replies
well one would work in app dir and both in pages dir...
Answer
app dir requires
route.jsbut pages dir can be anything inside api folder
RhinelanderOP
But if i use posts.js in app dir it doesn't throw error it works as expected. But does that make route public?
route.js
its because Next.js doesn't care about
posts.js since its not a valid file namethe syntax is different from pages to app dir: https://nextjs.org/docs/app/building-your-application/routing/route-handlers