My API routes doesn't work
Unanswered
Ring-necked Duck posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Ring-necked DuckOP
Hello 🙂
I'm trying to test my API route with Postman. The structure of my next.js project resembles the one depicted on the right side of this image.
I have a simple route where the file is named hello.js and located in src/pages/api/hello.js. In Postman, I'm attempting to call http://localhost:3000/api/hello.
However, I'm encountering a 404 error. Below is the code in hello.js:
Could you please help me identify what might be causing this 404 error? 🙂
I'm trying to test my API route with Postman. The structure of my next.js project resembles the one depicted on the right side of this image.
I have a simple route where the file is named hello.js and located in src/pages/api/hello.js. In Postman, I'm attempting to call http://localhost:3000/api/hello.
However, I'm encountering a 404 error. Below is the code in hello.js:
export default function handler(req, res) {
res.status(200).json({ message: 'Request successful' });
}
Could you please help me identify what might be causing this 404 error? 🙂
![Image](https://cdn.discordapp.com/attachments/1221161629513809920/1221161629904011344/top-level-folders.avif?ex=66119264&is=65ff1d64&hm=024d85b7a90706ab47d8908897bdac6147b0c215480f6d35070b8f768d33a540&)
1 Reply
![Avatar](https://cdn.discordapp.com/embed/avatars/3.png)
Chinese Egret
Are you sure the port number is correct ?