diff --git a/packages/frontend/src/environments/environment.selfhost.ts b/packages/frontend/src/environments/environment.selfhost.ts index 3f0562ab0..f410ece48 100644 --- a/packages/frontend/src/environments/environment.selfhost.ts +++ b/packages/frontend/src/environments/environment.selfhost.ts @@ -9,6 +9,12 @@ export const ENABLE_ANALYTICS = false; export const STRIPE_PK = ""; export const API_BASE_URL = "api/"; -export const GRIP_WS_URL = "grip/ws"; + +// Selfhost requires some extra sniffing to determine base url for WS since +// ws can't be "relative" via just `grip/ws` like `api/` can. +const wsProto = window.location.protocol === "https:" ? "wss:" : "ws:"; +const path = window.location.pathname; +const extraSlash = path.endsWith("/") ? "" : "/"; +export const GRIP_WS_URL = `${wsProto}//${window.location.host}${path}${extraSlash}grip/ws`; export const SENTRY_SAMPLE_RATE = 0;