Skip to content

Commit dcce159

Browse files
author
kaptron
committed
Drop /cable requests to 404 if using AnyCable
1 parent b19faa9 commit dcce159

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Procfile.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
web: bin/rails server -p 3000
22
webpack: bin/webpack-dev-server
33
worker: bundle exec sidekiq -e ${RACK_ENV:-development} -C config/sidekiq.yml
4+
cable: ANYCABLE_DEPLOYMENT=true bundle exec anycable --server-command="anycable-go --host=localhost --port=3334"

app/controllers/home_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def sign_out_and_redirect
3939
redirect_to url
4040
end
4141

42+
def not_found
43+
render plain: 'not found', status: :not_found
44+
end
45+
4246
before_action :require_dev_env, only: [:login_as]
4347
def login_as
4448
u = User.find(params[:id]) if params[:id]

config/routes.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
root to: 'home#index', constraints: ->(req) { req.format == :html || req.format == '*/*' }
1515
end
1616

17-
mount ActionCable.server => '/cable'
17+
if ENV['ACTION_CABLE_ADAPTER'] != 'anycable' || ENV['ANYCABLE_DEPLOYMENT']
18+
mount ActionCable.server => '/cable'
19+
else
20+
get 'cable', to: 'home#not_found'
21+
end
1822

1923
namespace :api do
2024
namespace :v1 do

0 commit comments

Comments
 (0)