]> git.ardis.lu - ardislu.dev/commitdiff
Delete environment variable substring
authorArdis Lu <ardisglu@gmail.com>
Fri, 25 Mar 2022 07:18:56 +0000 (00:18 -0700)
committerArdis Lu <ardisglu@gmail.com>
Fri, 25 Mar 2022 07:18:56 +0000 (00:18 -0700)
functions/api.js

index 39271c12d84cbf10a6cb911cf4d4fa863a5a74cb..70ec52b6353751f6d5fabb9d197f0e3e563dd596 100644 (file)
@@ -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);
 
This page took 0.033514 seconds and 4 git commands to generate.