[英]'Access-Control-Allow-Origin' issue
我有一个带有Rails后端的棱角前端。
我有这样的角度代码:
$http({method: 'GET', url: 'http://localhost:3000/products.json'}).
success(function(data, status, headers, config) {
$scope.data = data;
}).
error(function(data, status, headers, config) {
$scope.status = status;
});
我一直No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4000' is therefore not allowed access.
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4000' is therefore not allowed access.
错误,所以我使用了https://stackoverflow.com/a/17815546/561634,所以我的config / application.rb具有:
config.action_dispatch.default_headers = {
'Access-Control-Allow-Origin' => '*',
'Access-Control-Request-Method' => '*'
}
在里面。 不幸的是,这并没有改变错误。
感谢您的帮助!
请确保您的后端没有错误,该错误将导致“ 500-内部服务器错误”,因为在这种情况下,可能不会发送“ Access-Control”标头。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.