# HG changeset patch # User Kim Alvefur # Date 1480937021 -3600 # Node ID c5ce14539fc4071a3469638a4a3380b1c7deeb5d # Parent 2208e6cd0d9f01a8aa975e9764a9cb0172bfaa3b mod_websocket: Add the base URL of each host module is enabled on to 'cross_domain_websocket' diff -r 2208e6cd0d9f -r c5ce14539fc4 plugins/mod_websocket.lua --- a/plugins/mod_websocket.lua Mon Dec 05 12:22:41 2016 +0100 +++ b/plugins/mod_websocket.lua Mon Dec 05 12:23:41 2016 +0100 @@ -315,4 +315,17 @@ }; }); module:hook("c2s-read-timeout", keepalive, -0.9); + + if cross_domain ~= true then + local url = require "socket.url"; + local ws_url = module:http_url("websocket", "xmpp-websocket"); + local url_components = url.parse(ws_url); + -- The 'Origin' consists of the base URL without path + url_components.path = nil; + local this_origin = url.build(url_components); + cross_domain:add(this_origin); + function module.unload() + cross_domain:remove(this_origin); + end + end end