简体   繁体   中英

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

我通过apache中的enable headers模块解决了它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM