I`m working on a project in JavaScript and basically what I want is to send a post request to my server in order to perform a login. So I do that as it fallows: in Index.html
     <input type="button" name="" value="Login" id="login" onclick=doLogin() onsubmit="return false">
and I have a user.js
function doLogin() {
    let email = $('#emailLogin').val().trim();
    if(email === ""){
        email = null;
    }
    let password = $('#passwordLogin').val().trim();
    if(password === ""){
        password = null;
    }
    sendLoginRequest(email,password,getLoginSuccessHandler,getLoginErrorHandler);
}
function sendLoginRequest(email, password, successHandler, errHandler) {
    localStorage.removeItem('auth');
    localStorage.setItem('auth', btoa(email + ":" + password));
    let data = {email: email, password: password};
    jQuery.ajax({
        type: 'POST',
        url: getURL() + "user/login",
        contentType: "application/json",
        headers: { 'Authorization' : 'Basic ' + getAuth()
        },
        data: JSON.stringify(data),
        dataType: "json",
        accepts: "application/json",
        success: function (data, status, jqXHR) {
            successHandler(data);
        },
        error: function (jqXHR, message) {
            errHandler(jqXHR.responseText.message);
        }
    });
}
So when I press the button the page will send an OPTIONS request not a POST request. And in the console the message it printed like that: HTTP403: FORBIDDEN - The server understood the request, but is refusing to fulfill it. (XHR)OPTIONS - http://localhost:port/user/login
 
    