From 743aac2cb635fe2319e60ac40472102a904f6072 Mon Sep 17 00:00:00 2001 From: EresDev Date: Wed, 17 Jul 2024 23:44:27 +0500 Subject: [PATCH] fix: change sandbox env var to string --- functions/helpers.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/helpers.ts b/functions/helpers.ts index 02d0be48..a070c3e0 100644 --- a/functions/helpers.ts +++ b/functions/helpers.ts @@ -8,7 +8,7 @@ export const commonHeaders = { }; export interface Env { - USE_RELOADLY_SANDBOX: boolean; + USE_RELOADLY_SANDBOX: string; RELOADLY_API_CLIENT_ID: string; RELOADLY_API_CLIENT_SECRET: string; } @@ -21,7 +21,7 @@ export interface ReloadlyAuthResponse { } export async function getAccessToken(env: Env): Promise { - console.log("Using Reloadly Sandbox:", env.USE_RELOADLY_SANDBOX !== false); + console.log("Using Reloadly Sandbox:", env.USE_RELOADLY_SANDBOX !== "false"); const url = "https://auth.reloadly.com/oauth/token"; const options = { @@ -31,7 +31,7 @@ export async function getAccessToken(env: Env): Promise { client_id: env.RELOADLY_API_CLIENT_ID, client_secret: env.RELOADLY_API_CLIENT_SECRET, grant_type: "client_credentials", - audience: env.USE_RELOADLY_SANDBOX === false ? "https://giftcards.reloadly.com" : "https://giftcards-sandbox.reloadly.com", + audience: env.USE_RELOADLY_SANDBOX === "false" ? "https://giftcards.reloadly.com" : "https://giftcards-sandbox.reloadly.com", }), }; @@ -40,7 +40,7 @@ export async function getAccessToken(env: Env): Promise { const successResponse = (await res.json()) as ReloadlyAuthResponse; return { token: successResponse.access_token, - isSandbox: env.USE_RELOADLY_SANDBOX !== false, + isSandbox: env.USE_RELOADLY_SANDBOX !== "false", }; } throw `Getting access token failed: ${JSON.stringify(await res.json())}`;