尝试使用AppGyver的Supersonic创建我的第一个混合应用程序。这是角度$http请求,在ios模拟器中工作良好
$http.get('http://localhost:3000/api/get_data').success (data, status) ->
console.log data
但是在android上我遇到了CORS的问题,这是我在控制台中得到的错误
XMLHttpRequest cannot load http://localhost:3000/api/get_data. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
在Rails中有服务器,这里是控制器
after_filter :set_access_control_headers
def set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Request-Method'] = '*'
end
和头部设置良好,我可能需要改变超音速配置?有人用超音速吗?
发布于 2015-04-17 11:08:01
当我在这篇文章中遇到一些错误时,请看一下这一点。我分享这篇文章,希望对其他人也有帮助。http://www.tsheffler.com/blog/?p=428
另请参阅以下内容:
https://stackoverflow.com/questions/29697377
复制相似问题