I am trying to login through a different domain while my server is present on the another one.My loginmodule.js collects username and password from HTML page below is the code.i am also allowing cors in the code.
var name=$('#username').val();
var pass=$('#password').val();
var surl = "http://192.168.2.33:3000/users/login/";
console.log('link');
$.ajax({
type: 'POST',
url: surl,
crossDomain: true,
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ username:'name', password:'pass'}),
dataType: "json",
async: true,
cache: false,
success: function(responseText,status){
if(status=='true') console.log('success');
}
});
This is giving me a 401 unauthorized error. What should be included in my server.js file to avoid the same.
via KRISHNA
No comments:
Post a Comment