Erro 502 on orders Hook

Hello, I am trying to configure an orders hook to consume orders updates. But, although I am answering it with status code 200, I am receiving status 502 through the hook config endpoint with the following message:

{"errorType":"TypeError","errorMessage":"res.setHeader is not a function" ...

I tried with both a python function and a javascript function. Here is the js code I am using:

exports.main = (req, res) => {
  const secret = process.env.SECRET;
  const incomingSecret = req.header('Secret');

  if (incomingSecret !== secret) {
    console.error(`Unauthorized`);
    res.status(401).end();
    return;
  }

  console.log('Webhook received:', req.body);
  res.status(200).end();
};

The Hook seems to be successfully configured because I received some orders there, but I want to be sure the API will be able to retry when and just when needed.

Hello Gabriel,

Checking on my end for other cases like this, I believe it might have been a instability in the connection that resolved itself. In other examples I was able to find on my end, even with the 502 response the configs were saved properly like you mentioned.

If there are no issues with the orders themselves, I believe this can be disregarded.