I'm trying to make a post request to server and want to send the token with header .
But then my post request is not working and i can confirm it by because i'm logging in server if that post api got hit or not
and its logging when i don't attach headers and when i attach its not logging anything it's like request never hit up the server.
This code works :
 $.ajax({
    url: 'http://localhost:8080/newUrl',
    type: 'post',
    data: {
        url: myUrl
    },
    dataType: 'json',
    success: function (data) {
        alert(data);
    }
    });
This one doesn't :
 $.ajax({
    url: 'http://localhost:8080/newUrl',
    type: 'post',
    data: {
        url: myUrl
    },headers: {
      Authorization: token
  },
    dataType: 'json',
    success: function (data) {
        alert(data);
    }
});
Also this one doesn't :
$.ajaxSetup({
    headers:{
       'Authorization': token
    }
 });
  $.ajax({
    url: 'http://localhost:8080/newUrl',
    type: 'post',
    data: {
        url: myUrl
    },
    dataType: 'json',
    success: function (data) {
        alert(data);
    }
});
**node.js server CORS related stuff : **
app.use(function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    next();
  });
Console error : Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response
