Next JS API Route Never Returns HTTP Status

Hey Folks, I have a very basic REST API route (Its a web hook so it cant be a TRPC route) that checks if the request type is POST and if so returns a status of 200. However, when I try to use this the request times out and never returns a response. Could anyone point me in the right direction? Here is the route:
import type { NextApiRequest, NextApiResponse } from "next";

export default async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method == "POST") {
return res.status(200);
} else {
return res.status(405);
}
};
import type { NextApiRequest, NextApiResponse } from "next";

export default async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method == "POST") {
return res.status(200);
} else {
return res.status(405);
}
};
2 Replies
dan
dan3y ago
iirc you need to actually send the response, return res.status(200).send()
Liam
LiamOP3y ago
Yeah, that's what I ended up doing but send() would not take no arguments so instead I have just been sending an empty json object.
Want results from more Discord servers?
Add your server