Big News! Split is now part of Harness. Learn more at Harness and read why we are excited by this move.

The Split Blog

FEATURES ON FEATURES MANAGEMENT

Consider this your content source for articles about feature flagging, continuous delivery, measurement, and learning. Get practical tips, best practices strategies, and even code tutorials to guide your feature management journey.

const jwt = require("jsonwebtoken");

const config = process.env;

const verifyToken = (req, res, next) => {
  const token =
    req.body.token || req.query.token || req.headers["x-access-token"];

  if (!token) {
    return res.status(403).send("A token is required for authentication");
  }

  try {
    req.user = jwt.verify(token, config.TOKEN_KEY);
  } catch (err) {
    return res.status(401).send("Invalid Token");
  }

  return next();
};

module.exports = verifyToken;

Posts

Load More