简体   繁体   English

Ruby on Rails:如何通过 ngrok 访问 Action Cable?

[英]Ruby on Rails: How can I access Action Cable through ngrok?

I started the puma server as normal as port 3000. In my development file, I have:我像正常的端口 3000 一样启动了 puma 服务器。在我的开发文件中,我有:

config.action_cable.url = "wss://xxxxxx.ngrok.io/cable"
config.action_cable.allowed_request_origins = [/http:\/\/*/, /https:\/\/*/]

However when I start the app, I get this issue in Chrome console:但是,当我启动应用程序时,我在 Chrome 控制台中遇到了这个问题:

WebSocket connection to 'wss://xxxxxx.ngrok.io/cable' failed: 

I disabled my firewall settings too and still get the same issue.我也禁用了我的防火墙设置,但仍然遇到同样的问题。 Is there a correct way to access Action Cable web sockets through ngrok?有没有通过 ngrok 访问 Action Cable web sockets 的正确方法?

One solution that worked for me is to add this to config/development.rb:对我有用的一种解决方案是将其添加到 config/development.rb:

config.action_cable.disable_request_forgery_protection = true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM