Skip to content

Commit 9126578

Browse files
committed
Merge pull request #277 from cheesykyle/master
Fix LiveQuery SSL
2 parents a2b5507 + bec4739 commit 9126578

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/ParseLiveQuery.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,17 @@ let DefaultLiveQueryController = {
101101
if (liveQueryServerURL && liveQueryServerURL.indexOf('ws') !== 0) {
102102
throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
103103
}
104-
104+
105105
// If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
106106
if (!liveQueryServerURL) {
107-
let host = CoreManager.get('SERVER_URL').replace(/^https?:\/\//, '');
108-
liveQueryServerURL = 'ws://' + host;
107+
const tempServerURL = CoreManager.get('SERVER_URL');
108+
let protocol = 'ws://';
109+
// If Parse is being served over SSL/HTTPS, ensure LiveQuery Server uses 'wss://' prefix
110+
if (tempServerURL.indexOf('https') === 0) {
111+
protocol = 'wss://'
112+
}
113+
const host = tempServerURL.replace(/^https?:\/\//, '');
114+
liveQueryServerURL = protocol + host;
109115
CoreManager.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);
110116
}
111117

0 commit comments

Comments
 (0)