Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

chore: move backend urls to env variables

Andrew Bastina78462fbe3a8
diff --git a/packages/hoppscotch-app/.env.example b/packages/hoppscotch-app/.env.example
index 7c67ad4b6..2f2d14276 100644
--- a/packages/hoppscotch-app/.env.example
+++ b/packages/hoppscotch-app/.env.example
@@ -16,3 +16,7 @@ MEASUREMENT_ID=G-BBJ3R80PJT
# Base URL
BASE_URL=https://hoppscotch.io
+
+# Backend URLs
+BACKEND_GQL_URL=https://api.hoppscotch.io/graphql
+BACKEND_WS_URL=wss://api.hoppscotch.io/graphql
diff --git a/packages/hoppscotch-app/helpers/backend/GQLClient.ts b/packages/hoppscotch-app/helpers/backend/GQLClient.ts
index 69d323180..ae8aa012f 100644
--- a/packages/hoppscotch-app/helpers/backend/GQLClient.ts
+++ b/packages/hoppscotch-app/helpers/backend/GQLClient.ts
@@ -45,28 +45,23 @@ import {
} from "~/helpers/fb/auth"
const BACKEND_GQL_URL =
- process.env.context === "production"
- ? "https://api.hoppscotch.io/graphql"
- : "https://api.hoppscotch.io/graphql"
+ process.env.BACKEND_GQL_URL ?? "https://api.hoppscotch.io/graphql"
+const BACKEND_WS_URL =
+ process.env.BACKEND_WS_URL ?? "wss://api.hoppscotch.io/graphql"
// const storage = makeDefaultStorage({
// idbName: "hoppcache-v1",
// maxAge: 7,
// })
-const subscriptionClient = new SubscriptionClient(
- process.env.context === "production"
- ? "wss://api.hoppscotch.io/graphql"
- : "wss://api.hoppscotch.io/graphql",
- {
- reconnect: true,
- connectionParams: () => {
- return {
- authorization: `Bearer ${authIdToken$.value}`,
- }
- },
- }
-)
+const subscriptionClient = new SubscriptionClient(BACKEND_WS_URL, {
+ reconnect: true,
+ connectionParams: () => {
+ return {
+ authorization: `Bearer ${authIdToken$.value}`,
+ }
+ },
+})
authIdToken$.subscribe(() => {
subscriptionClient.client?.close()