In client side I have written my code as below,
$.ajax({
type: "GET",
beforeSend: function (request) {
var jwt = document.head.querySelector("[name~=token][content]").content;
request.setRequestHeader("Authorization", 'JWT '+ jwt);
},
url: "/test",
success: function(data){
alert("success");
}
});using this ajax request from client side I want to get the data on server side by authenticating the jwt token sent from client side. Server side(router code) is below,
app.get('/test', addon.checkValidToken(), function(req, res){
....
});
So, how can I authenticate or validate the url using jwt token by sending through request.SetHeaderRequest? I referred this url, but I couldn't figure out any solution for it.