Security error using CORS in IE10 with Node and Express

一曲冷凌霜 提交于 2019-11-29 15:39:39

Try sending the request to the API server using HTTP instead of HTTPS. The issue sounds like it may have to do with the server's SSL settings more so than the request itself. If this is the case try using SSL settings to something like this.

var options = {
  key:    fs.readFileSync(key),
  cert:   fs.readFileSync(certificate),
  ca:     fs.readFileSync(CA),
  requestCert:        false,
};

https.createServer(options, app).listen(443);

I had the same problem, finally to make things easier I did a nginx proxy_pass directive So I made http://example.com/api point to http://api.example.com
Then in the javascript code will request to example.com/api and the browser will not complain.

I know that this is not ideal, but not all browser support CORS in the same way, especially IE. When you want to give support all the browsers the proxy_pass option is the simplest way.

In other case you'll be making changes to make things work in IE and breaking other browsers support. Not saying that it's impossible, but it will take more testing.

To get my CORS request to work in IE, I had to make my call like this:

$.ajax({
  url: apiRoot + "/endpoint",
  xhrFields: {
     withCredentials: true
  },
  crossDomain: true,
  success: function(response) {
    // Omitted irrelevant code
  }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!