I’m new to web development. I’m hosting through Heroku and have registered my domain on Cloudflare, including one subdomain on Heroku.
I am using Postman to forward all methods like POST, DELETE, PATCH, and PUT to that subdomain to my server, but Cloudflare appears to be replacing them with GET. As a result, my API is not functioning properly because I am handling endpoints with PUT that should be handled with POST.
What do I need to set in Cloudflare or Heroku to fix this?
this is my example code
router.put('', checkApiKey, async (req, res) => {
try {
const updatedAccount = await AccountSchema.findOneAndUpdate(makeQuery(req), req.body, { new: true, runValidators: true });
if (!updatedAccount) throw Error('계좌 없음');
res.status(200).json(updatedAccount);
} catch (err) {
res.status(400).json({ message: err.message });
}
});
It works fine on the client (localhost) but not on the server, so I tried connecting to my server through an address ending in .herokuapp.com, which is given by default when deployed on heroku, and it worked fine.
And even if I send a POST via postman, it is displayed as GET in the heroku log.
As a result, I realized that the problem was in my domain settings.
uheej0625 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.