JavaScript - ошибки XMLHttpRequest, Access-Control-Allow-Origin

Я пытаюсь отправить запрос XMLHttpRequest на сайт вставки. Я отправляю объект, содержащий все поля, которые требует API, но я продолжаю получать эту проблему. Я перечитал вопрос и подумал:

httpReq.setRequestHeader('Access-Control-Allow-Headers', '*');

Исправил бы это, но это не так. У кого-нибудь есть информация об этой ошибке и / или как я могу это исправить?

Вот мой код:

(function () {

    'use strict';

    var httpReq = new XMLHttpRequest();
    var url = 'http://paste.ee/api';
    var fields = 'key=public&description=test&paste=this is a test paste&format=JSON';
    var fields2 = {key: 'public', description: 'test', paste: 'this is a test paste', format: 'JSON'};

    httpReq.open('POST', url, true);
    console.log('good');

    httpReq.setRequestHeader('Access-Control-Allow-Headers', '*');
    httpReq.setRequestHeader('Content-type', 'application/ecmascript');
    httpReq.setRequestHeader('Access-Control-Allow-Origin', '*');
    console.log('ok');

    httpReq.onreadystatechange = function () {
        console.log('test');
        if (httpReq.readyState === 4 && httpReq.status === 'success') {
            console.log('test');
            alert(httpReq.responseText);
        }
    };

    httpReq.send(fields2);

}());

А вот точный вывод консоли:

good
ok
Failed to load resource: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:40217' is therefore not allowed access. http://paste.ee/api
XMLHttpRequest cannot load http://paste.ee/api. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:40217' is therefore not allowed access. index.html:1
test

Вот вывод консоли при локальном тестировании в обычном браузере Chromium:

good
ok
XMLHttpRequest cannot load http://paste.ee/api. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. index.html:1
test

Ответы на вопрос(2)

Ваш ответ на вопрос