DELETE and PUT request response ERROR

DELETE and PUT request response ERROR
Method DELETE is not allowed by Access-Control-Allow-Methods in preflight response.

return Observable.fromPromise(new Promise((resolve, reject) => {
    let xhr = new XMLHttpRequest();

    let data = new FormData();
    data.append("api_key", user.api_key);
    data.append("api_username", user.api_username);
    data.append("post_action_type_id", topicActionsId);

    xhr.onreadystatechange = function() {
      if (xhr.readyState === 4) {
        if (xhr.status === 200) {
          resolve(JSON.parse(xhr.response));
        } else {
          reject(xhr.response);
        }
      }
    };

    xhr.open('DELETE','http://dogwelder.pocketgems.com/post_actions/' + topicId, true);
    xhr.setRequestHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, DELETE');
    xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
    xhr.setRequestHeader('Access-Control-Allow-Headers', 'Content-Type')
    xhr.send(data);
  }));
1 Like