尝试使用ActionCable时,Rails 5.0.0.beta2中的应用程序出现服务器问题.
使用localhost:3000可以正常工作,因为这是大多数ActionCable默认的.但是,如果我尝试在端口3001上运行rails服务器,它会给我Request origin not allowed: http://localhost:3001
ActionCable文档提到使用类似的东西ActionCable.server.config.allowed_request_origins = ['http://localhost:3001'],如果我把它放入其中对我有用config.ru
但这似乎是一个非常奇怪的地方.我觉得它应该能够进入初始化文件或我的development.rb环境配置文件.
为了进一步证明我应该允许它进入那里,该设置ActionCable.server.config.disable_request_forgery_protection = true可以忽略请求源,即使我将它包含在development.rb中也是如此.
为什么会ActionCable.server.config.disable_request_forgery_protection在development.rb中工作,但ActionCable.server.config.allowed_request_origins不能(但在config.ru中工作)?
这不是一个紧迫的问题,因为我有几种选择作为解决方法.我只是想知道我是否遗漏了一些明显的关于我认为这应该如何工作的东西.