【发布时间】:2014-03-24 21:27:19
【问题描述】:
我正在使用 Ember App Kit 尝试构建一个登录到现有服务器的应用程序。 我的问题是我收到以下消息:
XMLHttpRequest cannot load https://example.server.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.
我已经在 Google 上搜索过了,似乎我需要在我的 express-server 中添加/启用 CORS。 我尝试了以下各种示例,例如:
- https://www.npmjs.org/package/cors
- https://github.com/troygoode/node-cors
- http://bannockburn.io/2013/09/cross-origin-resource-sharing-cors-with-a-node-js-express-js-and-sencha-touch-app/
但我无法让它运行。
简而言之,我正在尝试查找如何将 CORS 添加到我的 express-server 的示例
干杯,
医生
【问题讨论】:
-
您是否允许 jQuery 进行跨域 ajax 调用。
$.ajaxSetup({crossDomain: true});