From d1eb694c30025990eeed6aef83f0f2a6ff272fd2 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 5 Dec 2016 12:23:41 +0100 Subject: mod_websocket: Add the base URL of each host module is enabled on to 'cross_domain_websocket' --- plugins/mod_websocket.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'plugins/mod_websocket.lua') diff --git a/plugins/mod_websocket.lua b/plugins/mod_websocket.lua index 10aa0d38..f6525df5 100644 --- a/plugins/mod_websocket.lua +++ b/plugins/mod_websocket.lua @@ -315,4 +315,17 @@ function module.add_host(module) }; }); 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 -- cgit v1.2.3