gpt4 book ai didi

ruby-on-rails - ActionCable 在子域而不是子目录上

转载 作者:行者123 更新时间:2023-12-02 20:08:24 24 4
gpt4 key购买 nike

我正在尝试让 ActionCable 在子域上工作。

问题是,一旦我更改以下行

config.action_cable.mount_path = '/'

该应用程序不再运行。但 ActionCable 在子域上工作。是否有任何解决方案可以在没有子目录(如 /cable)的子域上运行 ActionCable?

最佳答案

如果您不使用带有子 uri 的应用内服务器,您似乎需要将其作为独立服务器运行:https://github.com/rails/rails/tree/master/actioncable#consumer-configuration

您可以像这样指定电缆网址:

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:

# 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/bash
bundle exec puma -p 28080 cable/config.ru

https://github.com/rails/rails/tree/master/actioncable#standalone

关于ruby-on-rails - ActionCable 在子域而不是子目录上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45798602/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com