From a571786266b940e615c9df9d97f4f9d0de91b452 Mon Sep 17 00:00:00 2001 From: Gonzalo Date: Wed, 25 May 2022 15:07:39 +0200 Subject: [PATCH] Fix typo SCOPES + redict_uri in .env Changed to SCOPES to read from .env and expand REDIRECT_URI to be defined on .env too. --- index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 47ab916..580fe1c 100644 --- a/index.js +++ b/index.js @@ -31,13 +31,15 @@ const CLIENT_SECRET = process.env.CLIENT_SECRET; // Scopes for this app will default to `crm.objects.contacts.read` // To request others, set the SCOPE environment variable instead let SCOPES = ['crm.objects.contacts.read']; -if (process.env.SCOPE) { - SCOPES = (process.env.SCOPE.split(/ |, ?|%20/)).join(' '); +if (process.env.SCOPES) { + SCOPES = (process.env.SCOPES.split(/ |, ?|%20/)).join(' '); } // On successful install, users will be redirected to /oauth-callback -const REDIRECT_URI = `http://localhost:${PORT}/oauth-callback`; - +let REDIRECT_URI = `http://localhost:${PORT}/oauth-callback`; +if (process.env.REDIRECT_URI) { + REDIRECT_URI = process.env.REDIRECT_URI.replace("${PORT}", PORT); +} //===========================================================================// // Use a session to keep track of client ID