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

Have you enabled CORS?

4 Likes

@eviltrout Is it possible to enable CORS from administrative area? Because not sure our plan allows to edit app.xml file…

I mean we have added from Admin URL for CORS. Why DELETE and PUT requests still not working? Is it possible to fix it from Admin?

CORS enabled
GET and POST methods working
But we have problems with DELETE and PUT requests
Also when CORS plugin enabled in browser they working.

1 Like

Did you solve your issue ?