From 74f1f4c07111312a1b879ae34291812ee1d1e63b Mon Sep 17 00:00:00 2001 From: Zachary Chai Date: Thu, 16 Feb 2017 10:29:08 -0500 Subject: [PATCH] allow different action cable host --- app/assets/javascripts/cable.js | 7 ++++++- app/assets/javascripts/meeting.coffee | 4 ++-- app/views/layouts/application.html.erb | 28 ++++++++++++++------------ config/environments/production.rb | 1 - 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index 85c0230b..2d1696df 100644 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -22,8 +22,13 @@ //= require_tree ./channels (function() { + var protocol = window.location.protocol === "https:" ? "wss://" : "ws://"; + var host = window.GreenLight.WEBSOCKET_HOST || window.location.host + window.GreenLight.RELATIVE_ROOT; + var path = window.GreenLight.WEBSOCKET_PATH || '/cable'; + var url = protocol + host + path; + this.App || (this.App = {}); - App.cable = ActionCable.createConsumer(); + App.cable = ActionCable.createConsumer(url); }).call(this); diff --git a/app/assets/javascripts/meeting.coffee b/app/assets/javascripts/meeting.coffee index c79ea908..7cbfd321 100644 --- a/app/assets/javascripts/meeting.coffee +++ b/app/assets/javascripts/meeting.coffee @@ -47,8 +47,8 @@ class @Meeting url = location.protocol + '//' + location.hostname if location.port url += ':' + location.port - if GreenLight.relative_root - url += GreenLight.relative_root + if GreenLight.RELATIVE_ROOT + url += GreenLight.RELATIVE_ROOT return url # Sends the end meeting request diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 81d924e7..d7584fce 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -18,7 +18,7 @@ with BigBlueButton; if not, see . Greenlight <%= csrf_meta_tags %> - + <% if relative_root != '/b' %> @@ -26,6 +26,20 @@ with BigBlueButton; if not, see . <% else %> <%= stylesheet_link_tag 'fa/gl-fa', media: 'all', 'data-turbolinks-track': 'reload' %> <% end %> + + + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> @@ -54,15 +68,3 @@ with BigBlueButton; if not, see . - - - diff --git a/config/environments/production.rb b/config/environments/production.rb index c2de9949..5d91a027 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -65,7 +65,6 @@ Rails.application.configure do unless ENV["RAILS_ACTION_CABLE_FORGERY_PROTECTION"].present? Rails.application.config.action_cable.disable_request_forgery_protection = true end - # config.action_cable.allowed_request_origins = ["https://#{ENV['HOSTNAME']}", "http://#{ENV['HOSTNAME']}"] # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify