Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
build: update env variables according to nextjs docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dolcalmi committed May 3, 2022
1 parent 88ada8d commit c57c957
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 29 deletions.
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -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
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
28 changes: 7 additions & 21 deletions lib/config.ts
Original file line number Diff line number Diff line change
@@ -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 }
6 changes: 3 additions & 3 deletions lib/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c57c957

Please sign in to comment.