+10
-1
lib/frontend.js
+10
-1
lib/frontend.js
···
107
107
if (host && sbot.id && typeof sbot.id === 'string') {
108
108
var i = sbot.id.indexOf('.')
109
109
var key = i === -1 ? sbot.id.substring(1) : sbot.id.substring(1, i)
110
-
remote = 'ws://' + host + '~shs:' + key
110
+
111
+
var proto = 'http'
112
+
if (req.connection && req.connection.encrypted)
113
+
proto = 'https'
114
+
else if (req.headers && typeof req.headers['x-forwarded-proto'] === 'string')
115
+
proto = req.headers['x-forwarded-proto'].split(',')[0].trim()
116
+
117
+
var wsProto = proto === 'https' ? 'wss' : 'ws'
118
+
119
+
remote = wsProto + '://' + host + '~shs:' + key
111
120
}
112
121
113
122
return fs.readFile(patchbayIndex, 'utf8', function (err, html) {