Nextjs :- API resolved without sending a response
The endpoint that you're hitting are probably not returning anything to the browser. This normally happens when you trying to create dynamic routes for example.
You can try to use the following to force it to return "ok".
export default async function (req, res) {
try {
const response = "ok";
res.statusCode = 200;
res.setHeader('Content-Type', 'application/json');
res.setHeader('Cache-Control', 'max-age=180000');
res.end(JSON.stringify(response));
}
catch (error) {
res.json(error);
res.status(405).end();
}
}
Comments