I am trying to get ActionCable work on a subdomain.
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
?
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
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:
# 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With