Getting this to work wasn't the easiest of processes. I wasted a bit of time using the incorrect actioncable npm package. The correct one is https://www.npmjs.com/package/actioncable.
In Rails, you need to add the following to allow connections from not-port-3000 in development mode:
# config/initializers/cable.rb
if Rails.env.development?
Rails.application.config.action_cable.allowed_request_origins = ['http://localhost:5000', 'http://localhost:3000']
endNotes:
- I'm using create-react-app
- You
npm install actioncable --saveto install the correct actioncable package. Do not installaction-cableby mistake. - You can run it on not-port 3000 by
PORT=5000 npm start - I'm not authenticating the user at all; Rails wants you to do this with signed cookies, but this would be more difficult with auth tokens, etc.