Skip to content

Commit

Permalink
Merge pull request #260 from dolittle:wss-support
Browse files Browse the repository at this point in the history
Making WebSocketLink use WSS if origin is TLS
  • Loading branch information
einari authored Jul 2, 2021
2 parents b9974e9 + ac9f847 commit 0e14978
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Source/web/Bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client';
import { WebSocketLink } from '@apollo/client/link/ws';
import { WebSocketLink } from '@apollo/client/link/ws';
import { container } from 'tsyringe';
import { constructor } from '@dolittle/vanir-dependency-inversion';
import { DataSource } from './DataSource';
Expand Down Expand Up @@ -39,8 +39,9 @@ export class Bindings {
});
container.registerInstance(DataSource as constructor<DataSource>, dataClient);

const wsProtocol = document.location.protocol.indexOf('https') == 0 ? 'wss' : 'ws';
const subscriptionLink = new WebSocketLink({
uri: `ws://${window.location.host}${configuration.prefix}/graphql`,
uri: `${wsProtocol}://${window.location.host}${configuration.prefix}/graphql`,
options: {
reconnect: true
}
Expand Down

0 comments on commit 0e14978

Please sign in to comment.