From c57c95724baa1dc3ba4b825c2731d6f472b2cb17 Mon Sep 17 00:00:00 2001 From: Juan P Lopez Date: Mon, 2 May 2022 21:09:28 -0500 Subject: [PATCH] build: update env variables according to nextjs docs --- .env | 10 ++++++++++ .gitignore | 6 +----- lib/config.ts | 28 +++++++--------------------- lib/download.ts | 6 +++--- 4 files changed, 21 insertions(+), 29 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 00000000..36b39962 --- /dev/null +++ b/.env @@ -0,0 +1,10 @@ +NEXT_PUBLIC_GRAPHQL_HOSTNAME=api.mainnet.galoy.io +NEXT_PUBLIC_GRAPHQL_URI=https://$NEXT_PUBLIC_GRAPHQL_HOSTNAME/graphql +NEXT_PUBLIC_GRAPHQL_SUBSCRIPTION_URI=wss://$NEXT_PUBLIC_GRAPHQL_HOSTNAME/graphql + +GRAPHQL_HOSTNAME_INTERNAL=api.galoy-name-galoy.svc.cluster.local +GRAPHQL_URI_INTERNAL=http://$GRAPHQL_HOSTNAME_INTERNAL/graphql + +NEXT_PUBLIC_PLAY_STORE_LINK=https://play.google.com/store/apps/details?id=com.galoyapp +NEXT_PUBLIC_APP_STORE_LINK=https://apps.apple.com/app/bitcoin-beach-wallet/id1531383905 +NEXT_PUBLIC_APK_LINK=https://storage.googleapis.com/bitcoin-beach-wallet/latest.apk diff --git a/.gitignore b/.gitignore index 82a2d302..6141bf0a 100644 --- a/.gitignore +++ b/.gitignore @@ -14,14 +14,10 @@ tsconfig.tsbuildinfo # misc .DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local +.env*.local npm-debug.log* yarn-debug.log* yarn-error.log* public/env.js -.env .vscode/ diff --git a/lib/config.ts b/lib/config.ts index e9a6fe9f..a0e1c254 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -1,27 +1,13 @@ -let GRAPHQL_HOSTNAME = process.env.NEXT_PUBLIC_GRAPHQL_HOSTNAME as string +if (!process.env.NEXT_PUBLIC_GRAPHQL_HOSTNAME) { + throw new Error("NEXT_PUBLIC_GRAPHQL_HOSTNAME env variable is required") +} + +const GRAPHQL_URI = process.env.NEXT_PUBLIC_GRAPHQL_URI || "" +const GRAPHQL_SUBSCRIPTION_URI = process.env.NEXT_PUBLIC_GRAPHQL_SUBSCRIPTION_URI || "" // we need an internal dns to properly propagate the ip related headers to api // if we use the api endpoints, nginx will rewrite the header to prevent spoofing // for example: "api.galoy-name-galoy.svc.cluster.local" -const GRAPHQL_HOSTNAME_INTERNAL = process.env.GRAPHQL_HOSTNAME_INTERNAL as string - -// FIXME: remove once dns has been migrated out of ln.bitcoinbeach.com -if (!GRAPHQL_HOSTNAME) { - if (typeof window !== "undefined") { - let hostParts = window.location.host.split(".") - if (hostParts.length <= 3) { - // throw new Error("Missing env variables") - hostParts = "pay.mainnet.galoy.io".split(".") - } - hostParts[0] = "api" - GRAPHQL_HOSTNAME = hostParts.join(".") - } else { - GRAPHQL_HOSTNAME = "api.mainnet.galoy.io" - } -} - -const GRAPHQL_URI_INTERNAL = `http://${GRAPHQL_HOSTNAME_INTERNAL}/graphql` -const GRAPHQL_URI = `https://${GRAPHQL_HOSTNAME}/graphql` -const GRAPHQL_SUBSCRIPTION_URI = `wss://${GRAPHQL_HOSTNAME}/graphql` +const GRAPHQL_URI_INTERNAL = process.env.GRAPHQL_URI_INTERNAL || "" export { GRAPHQL_URI, GRAPHQL_SUBSCRIPTION_URI, GRAPHQL_URI_INTERNAL } diff --git a/lib/download.ts b/lib/download.ts index 1177ae50..3f58ec2c 100644 --- a/lib/download.ts +++ b/lib/download.ts @@ -25,6 +25,6 @@ export const getOS = () => { return undefined } -export const playStoreLink = "https://play.google.com/store/apps/details?id=com.galoyapp" -export const appStoreLink = "https://apps.apple.com/app/bitcoin-beach-wallet/id1531383905" -export const apkLink = "https://storage.googleapis.com/bitcoin-beach-wallet/latest.apk" +export const playStoreLink = process.env.NEXT_PUBLIC_PLAY_STORE_LINK +export const appStoreLink = process.env.NEXT_PUBLIC_APP_STORE_LINK +export const apkLink = process.env.NEXT_PUBLIC_APK_LINK