API showing 404 even though file is in app/api folder
Answered
Persian posted this in #help-forum
PersianOP
File structure is as follows, api is supposed to spit out John Doe on localhost:3000/api/hello but instead shows 404
example code would be nice
Thank you
example code would be nice
Thank you
Answered by joulev
it needs to be
app/api/hello/route.js since you are using the app directory6 Replies
@Persian File structure is as follows, api is supposed to spit out John Doe on localhost:3000/api/hello but instead shows 404
example code would be nice
Thank you
it needs to be
app/api/hello/route.js since you are using the app directoryAnswer
also the syntax is drastically different
not
export default function handler(req, res)@joulev it needs to be `app/api/hello/route.js` since you are using the app directory
PersianOP
thanks youre a god
if you want to keep the old syntax and the old way of doing it, then use the pages directory and use
pages/api/hello.js or pages/api/hello/index.js