mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-03-14 14:15:16 +09:00
Allow serving cable traffic under $SCRIPT_NAME
If deploying Campfire to a path other than the root (for example, using Kamal's path-based routing) then the Action Cable endpoint needs to be adjusted to include that path. Prepending the script name to the cable path means it will be adjusted to the path in the same way that the application routes are. When script name is the default, the behaviour is unchanged.
This commit is contained in:
7
app/helpers/cable_helper.rb
Normal file
7
app/helpers/cable_helper.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
module CableHelper
|
||||
def script_aware_action_cable_meta_tag
|
||||
tag.meta \
|
||||
name: "action-cable-url",
|
||||
content: "#{request.script_name}#{ActionCable.server.config.mount_path}"
|
||||
end
|
||||
end
|
||||
@@ -12,6 +12,7 @@
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
<%= current_user_meta_tags %>
|
||||
<%= script_aware_action_cable_meta_tag %>
|
||||
|
||||
<%= tag.meta name: "vapid-public-key", content: Rails.configuration.x.vapid.public_key %>
|
||||
<%= tag.meta name: "turbo-prefetch", content: "true" %>
|
||||
|
||||
Reference in New Issue
Block a user