Skip to content

Commit

Permalink
feat: add support for secure wss connection
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking committed Oct 18, 2024
1 parent acce9d9 commit 243c6fd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/src/RelayEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from "relay-runtime";

import { authFetch } from "@phoenix/authFetch";
import { BASE_URL } from "@phoenix/config";
import { BASE_URL, WS_BASE_URL } from "@phoenix/config";

const graphQLPath = BASE_URL + "/graphql";

Expand Down Expand Up @@ -56,8 +56,11 @@ const fetchRelay: FetchFunction = async (params, variables, _cacheConfig) => {
return json;
};

/**
* Check whether or not we are running
*/
const wsClient = createClient({
url: "ws://localhost:6006/graphql",
url: `${WS_BASE_URL}/graphql`,
});

const subscribe: SubscribeFunction = (
Expand Down
6 changes: 5 additions & 1 deletion app/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ function getSanitizedPath(path: string): string {
return path.endsWith("/") ? path.slice(0, -1) : path;
}

export const BASE_URL = `${window.location.protocol}//${window.location.host}${getSanitizedPath(window.Config.basename)}`;
const sanitizedPath = getSanitizedPath(window.Config.basename);
const isSecure = window.location.protocol === "https:";

export const BASE_URL = `${window.location.protocol}//${window.location.host}${sanitizedPath}`;
export const WS_BASE_URL = `${isSecure ? "wss" : "ws"}://${window.location.host}${sanitizedPath}`;
export const VERSION = window.Config.platformVersion;

0 comments on commit 243c6fd

Please sign in to comment.