I am trying to get ActionCable work on a subdomain.
我试图让ActionCable在子域上工作。
the problem is that as soon as I am changing the following line
问题是,只要我改变以下行
config.action_cable.mount_path = '/'
The app isn't working anymore. But ActionCable works on a subdomain. Is there any solution to run ActionCable on a subdomain without a subdir like /cable
?
该应用程序不再工作了。但ActionCable适用于子域。是否有任何解决方案在子域上运行ActionCable而没有像/ cable这样的子目录?
1 个解决方案
#1
3
It looks like you'll need to run it as a standalone server if you're not using an in-app server with a sub-uri: https://github.com/rails/rails/tree/master/actioncable#consumer-configuration
如果您没有使用带有子uri的应用内服务器,您似乎需要将其作为独立服务器运行:https://github.com/rails/rails/tree/master/actioncable#consumer -组态
You can specify the cable url like so:
您可以像这样指定电缆网址:
config.action_cable.url = 'ws://cable.example.com:28080'
The cable server(s) is separated from your normal application server. It's still a Rack application, but it is its own Rack application. The recommended basic setup is as follows:
有线服务器与普通应用程序服务器分开。它仍然是Rack应用程序,但它是自己的Rack应用程序。推荐的基本设置如下:
# cable/config.ru
require_relative '../config/environment'
Rails.application.eager_load!
run ActionCable.server
Then you start the server using a binstub in bin/cable ala:
然后使用bin / cable ala中的binstub启动服务器:
#!/bin/bash
bundle exec puma -p 28080 cable/config.ru
https://github.com/rails/rails/tree/master/actioncable#standalone
#1
3
It looks like you'll need to run it as a standalone server if you're not using an in-app server with a sub-uri: https://github.com/rails/rails/tree/master/actioncable#consumer-configuration
如果您没有使用带有子uri的应用内服务器,您似乎需要将其作为独立服务器运行:https://github.com/rails/rails/tree/master/actioncable#consumer -组态
You can specify the cable url like so:
您可以像这样指定电缆网址:
config.action_cable.url = 'ws://cable.example.com:28080'
The cable server(s) is separated from your normal application server. It's still a Rack application, but it is its own Rack application. The recommended basic setup is as follows:
有线服务器与普通应用程序服务器分开。它仍然是Rack应用程序,但它是自己的Rack应用程序。推荐的基本设置如下:
# cable/config.ru
require_relative '../config/environment'
Rails.application.eager_load!
run ActionCable.server
Then you start the server using a binstub in bin/cable ala:
然后使用bin / cable ala中的binstub启动服务器:
#!/bin/bash
bundle exec puma -p 28080 cable/config.ru
https://github.com/rails/rails/tree/master/actioncable#standalone