1

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); });
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
  • Do you have any code that generates this? – James A Mohler Apr 09 '18 at 03:45
  • The code request is: var settings = { "async": true, "crossDomain": true, "url": "http://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); }); I have already added headers in mantis config [LINK](https://stackoverflow.com/questions/44701216/how-to-make-http-request-to-mantisbts-rest-api-using-angular-http) – Irimescu Cosmin Apr 09 '18 at 06:55
  • Looks like you have a stray ; on the line with the url – James A Mohler Apr 09 '18 at 11:31
  • I wrote it accidentally when I replaced your comment :D – Irimescu Cosmin Apr 09 '18 at 14:21
  • Is it now correct? – James A Mohler Apr 09 '18 at 19:02
  • No, it doesn't work yet. As I say if I make a request from the same domain where I installed mantis it work but if I make a request from another domain or the same domain with different port browser return a preflight error in console. – Irimescu Cosmin Apr 10 '18 at 19:49
  • Whav version of ColdFusion are you running? Can you get a really rest example to work? Like a text file with JSON or something? – James A Mohler Apr 10 '18 at 20:01
  • I resolved it by enable headers module in apache. Thanks – Irimescu Cosmin Apr 17 '18 at 22:24
  • You should write that up as answer so that others can benefit from what you have learned – James A Mohler Apr 17 '18 at 23:01

1 Answers1

0

I resolved it by enable headers module in apache.