我正在尝试集成 omniauth google oath,虽然我可以通过 google plus 登录或创建新用户,但我在单击登录时收到此消息,但在请求结束时消失了。
XMLHttpRequest cannot load https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=924…scope=email+profile&state=7569c82117b4114fa45f63db7a7fe80f2c42232524224f2c.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:3000' is therefore not allowed access.
此外,在本地主机上,我可以使用 google plus 创建或登录,尽管出现错误 it doesn't work on heroku。
我搜索了很多,但即使我在我的 application.rb 文件中添加了如下代码
headers['Access-Control-Allow-Origin'] = 'http://localhost:3000'
我还是不太明白
最佳答案
拥有访问控制允许来源。您可以通过下面的链接 https://github.com/cyu/rack-cors
只需要安装 gem install rack-cors
然后按照 github 链接中的文档进行配置。 这可能有助于解决您的问题
关于ruby-on-rails - 请求的资源上不存在 'Access-Control-Allow-Origin' header - Rails 4.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31867080/