title: 403 forbidden on express. Can't accept Authorization header
body: <p>I have a REST Api, and all endpoints must send a response when the user has an authentication token (I use the jwt token).
  everything works fine when I test my code using postman, but from front not working(session closes after <strong>OPTION</strong> request, and on the request header bearer token not set).</p>
  
  <p><strong>Authentication Middleware</strong></p>
  
  <pre><code>module.exports = function(req, res, next) {
      const authorization = req.headers['authorization'];
      console.log(authorization);
      const token = authorization
        ? authorization.replace('Bearer ', '')
        : null;
  
      if (!token) 
        return res.status(403).send({ auth: false, message: 'No token provided.' });
  
      jwt.verify(token, config.secret, function(err, decoded) {      
        if (err) 
          return res.status(500).send({ auth: false, message: 'Failed to authenticate token.' });    
  
        req.userId = decoded.id;
        next();
      });
  }
  </code></pre>
  
  <p><strong>route</strong></p>
  
  <pre><code>const Router                = require('express').Router;
  
  //Authentication Middleware
  const requireAuthentication = require('../middlewares/').Auth()
  
  module.exports = () =&gt; {
    let router = new Router();
    router.use(requireAuthentication);
    router.use('/accounts', require('./account')());
    router.use('/projects', require('./projects')());
    return router;
  };
  </code></pre>
  
  <p>with authentication
  <a href="https://i.stack.imgur.com/cAFw5.png" rel="nofollow noreferrer">https://i.stack.imgur.com/cAFw5.png</a></p>
  
  <p>without authentication
  <a href="https://i.stack.imgur.com/VUuuv.png" rel="nofollow noreferrer">https://i.stack.imgur.com/VUuuv.png</a></p>