From 0b06ea32ac7a637757d8dcea0e8f79b33b45f000 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Fri, 25 Mar 2022 00:18:56 -0700 Subject: [PATCH] Delete environment variable substring --- functions/api.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/functions/api.js b/functions/api.js index 39271c1..70ec52b 100644 --- a/functions/api.js +++ b/functions/api.js @@ -63,10 +63,9 @@ export async function onRequestGet({ request, env }) { const url = new URL(request.url); const queryString = decodeURIComponent(url.search.substring(1)); - // Cloudflare Workers inserts "//" in front of all environment variables, need to delete it - const email = env.EMAIL.substring(2) // E.g. "example@example.com" - const privateKey = env.PRIVATE_KEY.substring(2) // E.g. "-----BEGIN PRIVATE KEY-----\n...EXAMPLE...\n-----END PRIVATE KEY-----\n" - const scopes = env.SCOPES.substring(2) // E.g. "https://example.com/auth/scope1 https://example.com/auth/scope2" + const email = env.EMAIL // E.g. "example@example.com" + const privateKey = env.PRIVATE_KEY // E.g. "-----BEGIN PRIVATE KEY-----\n...EXAMPLE...\n-----END PRIVATE KEY-----\n" + const scopes = env.SCOPES // E.g. "https://example.com/auth/scope1 https://example.com/auth/scope2" const token = await getGoogleAuthToken(email, privateKey, scopes); -- 2.47.3