Crossdomain ajax request to controller with requireAjaxRequest() I make request from my localhost(gulp server) to example domain in to VerifyPassword controller. When i make request without headers: {'X-Requested-With': 'XMLHttpRequest'}, It comes as expected 400 Bad request

$.ajax({
        url: 'http://example/index.php/actions/users/verifyPassword',
        type: 'POST',
        data: $data,
        xhrFields: {
            withCredentials: true
        },
        success(data, response) {
            console.log(data, response);
        },
        error(data, response) {
            console.log(response, data);
        }
});


When i make request with headers: {'X-Requested-With': 'XMLHttpRequest'} comes response XMLHttpRequest cannot load http://example/index.php/actions/users/verifyPassword. Response for preflight is invalid (redirect), and are not sent cookies. Done OPTIONS preflight request without cookies and server comes 302 and redirect to example/login.
How To be?



http://www.yiiframework.com/forum/index.php?/topic/4945-yiiapp-request-isajaxrequest/
Looking further into the problem, I've found that the page tries to do a post request to the other domain. It calls upon the action function in the UsersController.php file (Location: /craft/app/controllers/)

But because the user isn't logged in on the other domain and anonymous access isn't allowed for this action. You get redirected to /login to login on that domain.

https://craftcms.stackexchange.com/a/12268/635

The developers managed to solve this problem? This applies to almost all controllers require session.