Front end app - TOKEN problem at backend

Hi everyone,

I’m currently developing an item view application. The frontend app creates webhooks for the board, and these webhooks are received by my Node.js app. However, I’m facing an issue with the token when trying to use the Monday SDK on my backend. It appears that the item view app is designed to be a frontend application and doesn’t require a token. In my situation, my frontend is connected to the backend, and I want to utilize the Monday SDK in the backend.

hi @royalayofdigital

Wouldn’t you be able to just call the backend with the session token in the header. With fetch the options part would be:

{ method: "GET", headers: { Authorization: myToken, Accept: "application/json" } }

The route in you backend would be something like:

router.get("your-endpoint", authenticationMiddleware.authReact, async function (req, res) {
  var returnValue = await "YOUR MONDAY BACKEND FUNCTION, req.query.whatever);
  return res.send(returnValue);
});

where “whatever” is the query param which is send as part of the fetch URL

Now, to verify the token the middleware “authenticationMiddleware.authReact” would be:

async function authReact(req, res, next) {
  try {
    let { authorization } = req.headers;
    jwt.verify(authorization, "YOUR CLIENT SECRET");
    next();
  } catch (err) {
    res.status(401).json({ error: "not authenticated" });
  }
}