Skip to content

Fix LiveQuery SSL #277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/ParseLiveQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,17 @@ let DefaultLiveQueryController = {
if (liveQueryServerURL && liveQueryServerURL.indexOf('ws') !== 0) {
throw new Error('You need to set a proper Parse LiveQuery server url before using LiveQueryClient');
}

// If we can not find Parse.liveQueryServerURL, we try to extract it from Parse.serverURL
if (!liveQueryServerURL) {
let host = CoreManager.get('SERVER_URL').replace(/^https?:\/\//, '');
liveQueryServerURL = 'ws://' + host;
const tempServerURL = CoreManager.get('SERVER_URL');
let protocol = 'ws://';
// If Parse is being served over SSL/HTTPS, ensure LiveQuery Server uses 'wss://' prefix
if (tempServerURL.indexOf('https') === 0) {
protocol = 'wss://'
}
const host = tempServerURL.replace(/^https?:\/\//, '');
liveQueryServerURL = protocol + host;
CoreManager.set('LIVEQUERY_SERVER_URL', liveQueryServerURL);
}

Expand Down