1

i have a page that is hosted on both HTTP and HTTPS, and it makes a HTTP call with jquery to a local http server on the client computer with the following code:

var url = "http://127.0.0.1:1234/Ping";
var ajaxSettings = {
    url: url,
    timeout: 1000
};

return $.ajax(ajaxSettings);

the client application has the following headers:

  • Access-Control-Allow-Origin: *
  • Access-Control-Allow-Methods: GET
  • Access-Control-Allow-Headers: Accept, Origin, Content-type

This works great when using http but when using https i get a error.

Is there any way to solve this? (generating a ssl certificate and registering it seems a bit overkill)

Peter
  • 37,042
  • 39
  • 142
  • 198
  • What is the server used?And CORS need to be enabled from server end for https mode. – Shankar Shastri Aug 22 '16 at 11:34
  • well there are 2 servers involved the one that has the javascrip is a IIS server and the second on (installed on the client computer) is NancyFx based. – Peter Aug 22 '16 at 13:02
  • You can enable cors using this http://enable-cors.org/server_iis7.html http://stackoverflow.com/questions/15658627/is-it-possible-to-enable-cors-using-nancyfx – Shankar Shastri Aug 23 '16 at 06:14
  • The page containing javascript which issues CORS ajax request should have same protocol as used for the CORS request. – lubosdz Oct 05 '18 at 07:34

0 Answers0