restapicoldfusionmantis

API requests(Mantis BT) from another domain - preflight error


I'm developing a Mantis BT client in ColdFusion but I have a problem when I try to make requests from a different domain.

If I making requests from the same domain where I installed Mantis BT all work fine but when I try to make a request from a different domain or the same domain with another port(localhost:8500 - ColdFusion) the browser return "Failed to load https://localhost/mantis/api/rest/users/me: Response for preflight has invalid HTTP status code 401." error.

I have added all headers in mantis config but it still not working. If I try to make a request with postman all work fine.

var settings = { 
  "async": true,
  "crossDomain": true, 
  "url": "localhost:8080/mantis/api/rest/users/me", 
  "method": "GET", 
  "headers": { 
      'Access-Control-Expose-Headers': 'Access-Control-Allow-Origin',
      'Access-Control-Allow-Origin': '*', 
      'Authorization': 'MAzzT5UD4cjxwwOayyLFAXnlIPQJmiL_'
      }
  } 

  $.ajax(settings).done(function (response) { console.log(response); });

Solution

  • I resolved it by enable headers module in apache.