DELETE and PUT request response ERROR

AI-generated summary

The discussion revolves around a CORS issue where DELETE and PUT requests fail with a “Method DELETE is not allowed” error, despite CORS being enabled. Andrey_Veryovkin reports that GET and POST requests work, but DELETE and PUT do not, even though the CORS plugin is active in the browser. eviltrout suggests checking if CORS is properly enabled, while klalex asks if CORS can be configured via the admin panel without editing the app.xml file, noting that the required URLs are already added. Andrey_Veryovkin confirms CORS is enabled and that the issue persists only with DELETE and PUT requests. Edwin_Mhoy_Silva inquires if the issue was resolved.

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);
  }));

Have you enabled CORS?

@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.

Did you solve your issue ?