Next.js Discord

Discord Forum

Simple question about /api/posts/

Answered
Rhinelander posted this in #help-forum
Open in Discord
RhinelanderOP
What is difference between /api/posts/route.js vs /api/posts/posts.js
Answered by riský
well one would work in app dir and both in pages dir...
View full answer

7 Replies

well one would work in app dir and both in pages dir...
Answer
app dir requires route.js
but 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 name