chore: move backend urls to env variables

This commit is contained in:
Andrew Bastin
2022-06-07 01:57:48 +05:30
parent 52c25e497f
commit a78462fbe3
2 changed files with 15 additions and 16 deletions

View File

@@ -16,3 +16,7 @@ MEASUREMENT_ID=G-BBJ3R80PJT
# Base URL # Base URL
BASE_URL=https://hoppscotch.io BASE_URL=https://hoppscotch.io
# Backend URLs
BACKEND_GQL_URL=https://api.hoppscotch.io/graphql
BACKEND_WS_URL=wss://api.hoppscotch.io/graphql

View File

@@ -45,28 +45,23 @@ import {
} from "~/helpers/fb/auth" } from "~/helpers/fb/auth"
const BACKEND_GQL_URL = const BACKEND_GQL_URL =
process.env.context === "production" process.env.BACKEND_GQL_URL ?? "https://api.hoppscotch.io/graphql"
? "https://api.hoppscotch.io/graphql" const BACKEND_WS_URL =
: "https://api.hoppscotch.io/graphql" process.env.BACKEND_WS_URL ?? "wss://api.hoppscotch.io/graphql"
// const storage = makeDefaultStorage({ // const storage = makeDefaultStorage({
// idbName: "hoppcache-v1", // idbName: "hoppcache-v1",
// maxAge: 7, // maxAge: 7,
// }) // })
const subscriptionClient = new SubscriptionClient( const subscriptionClient = new SubscriptionClient(BACKEND_WS_URL, {
process.env.context === "production" reconnect: true,
? "wss://api.hoppscotch.io/graphql" connectionParams: () => {
: "wss://api.hoppscotch.io/graphql", return {
{ authorization: `Bearer ${authIdToken$.value}`,
reconnect: true, }
connectionParams: () => { },
return { })
authorization: `Bearer ${authIdToken$.value}`,
}
},
}
)
authIdToken$.subscribe(() => { authIdToken$.subscribe(() => {
subscriptionClient.client?.close() subscriptionClient.client?.close()