-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(pay): stop using NEXT_PUBLIC env vars
- Loading branch information
1 parent
623a25d
commit 59a37ac
Showing
10 changed files
with
63 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,44 @@ | ||
import { env } from "../env" | ||
export const USD_INVOICE_EXPIRE_INTERVAL = 60 * 5 | ||
export const MAX_INPUT_VALUE_LENGTH = 14 | ||
export const APP_DESCRIPTION = "Blink official lightning network node" | ||
|
||
// TODO get rid of this by removing the use of build time env vars in the client | ||
export const getClientSideGqlConfig = () => { | ||
const hostname = new URL(window.location.href).hostname | ||
|
||
let coreGqlUrl | ||
|
||
// Allow overriding the coreGqlUrl for local development, otherwise use the default in the URL | ||
if (env.NEXT_PUBLIC_CORE_GQL_URL || typeof window === "undefined") { | ||
coreGqlUrl = env.NEXT_PUBLIC_CORE_GQL_URL | ||
} else { | ||
const hostPartsApi = hostname.split(".") | ||
hostPartsApi[0] = "api" | ||
coreGqlUrl = `https://${hostPartsApi.join(".")}/graphql` | ||
} | ||
|
||
let coreGqlWebSocketUrl | ||
|
||
// Allow overriding the coreGqlWebSocketUrl for local development, otherwise use the default in the URL | ||
if (env.NEXT_PUBLIC_CORE_GQL_WEB_SOCKET_URL || typeof window === "undefined") { | ||
coreGqlWebSocketUrl = env.NEXT_PUBLIC_CORE_GQL_WEB_SOCKET_URL | ||
} else { | ||
const hostPartsWs = hostname.split(".") | ||
hostPartsWs[0] = "ws" | ||
coreGqlWebSocketUrl = `wss://${hostPartsWs.join(".")}/graphql` | ||
} | ||
|
||
return { | ||
coreGqlUrl: coreGqlUrl || "", | ||
coreGqlWebSocketUrl: coreGqlWebSocketUrl || "", | ||
} | ||
} | ||
|
||
export const getClientSidePayDomain = () => { | ||
if (env.NEXT_PUBLIC_PAY_DOMAIN || typeof window === "undefined") { | ||
return env.NEXT_PUBLIC_PAY_DOMAIN | ||
} else { | ||
return new URL(window.location.href).hostname.split(".").slice(-2).join(".") // Return the last two parts of the hostname (e.g. "blink.sv") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters