how to make an ajax call using basic auth
ekelvin opened this issue · comments
I am trying to use basicauth for ajax cors but the user and the password in the node server passport-http come undefined. What I am missing in here?
app.use(passport.initialize());
app.use(allowCrossDomain);
app.use(app.router);
where allowCrossDomain is for allowing cors requests
$.ajax
({
type: "POST",
url: "https://kelvin-new:8000/admin",
dataType: 'json',
crossDomain: true,
async: false,
username: $("#login#username").val(),
password: $("#login#password").val(),
beforeSend: function(xhr){
xhr.setRequestHeader("Authorization", "Basic " + btoa($("#login#username").val() + ":" + $("#login#password").val()))
},
data: '{ "comment" }',
withCredentials: true,
done: function (res){
alert('Thanks for your comment!');
},
error: function(error) {
alert(error.statusText);
}
});
my nobby mistake :(