From abeb44b86260ff15bc7c6afb25f2caa03d994308 Mon Sep 17 00:00:00 2001 From: Mario Sergio Date: Wed, 23 Oct 2024 15:08:49 -0300 Subject: [PATCH] fix(webpage-client): removed open api key from public config --- clients/packages/webpage-client/next.config.js | 12 +++++++----- .../src/pages/api/campaigns/[widget_id].ts | 9 +++------ .../src/pages/api/phone/[widget_id]/create.ts | 9 +++------ 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/clients/packages/webpage-client/next.config.js b/clients/packages/webpage-client/next.config.js index 304de574c..1049817da 100644 --- a/clients/packages/webpage-client/next.config.js +++ b/clients/packages/webpage-client/next.config.js @@ -25,18 +25,20 @@ module.exports = withTM( // So, the source code is "basePath-ready". // You can remove `basePath` if you don't need it. reactStrictMode: true, + // Variáveis acessíveis apenas no servidor (não expostas no cliente) + serverRuntimeConfig: { + apiGraphqlSecret: process.env.REACT_APP_API_GRAPHQL_SECRET, + pagarmeKey: process.env.REACT_APP_PAGARME_KEY, + openApiToken: process.env.REACT_APP_OPENAPI_TOKEN, + }, publicRuntimeConfig: { domainImaginary: process.env.REACT_APP_DOMAIN_IMAGINARY, domainApiRest: process.env.REACT_APP_DOMAIN_API_REST, domainApiGraphql: process.env.REACT_APP_DOMAIN_API_GRAPHQL, - apiGraphqlSecret: process.env.REACT_APP_API_GRAPHQL_SECRET, domainApiGraphqlWs: process.env.REACT_APP_DOMAIN_API_GRAPHQL_WS, domainPublic: process.env.REACT_APP_DOMAIN_PUBLIC, - pagarmeKey: process.env.REACT_APP_PAGARME_KEY, - openApiUrl: process.env.REACT_APP_OPENAPI_URL, - openApiToken: process.env.REACT_APP_OPENAPI_TOKEN, openApiCampaignId: process.env.REACT_APP_OPENAPI_CAMPAIGN_ID }, }) -); +); \ No newline at end of file diff --git a/clients/packages/webpage-client/src/pages/api/campaigns/[widget_id].ts b/clients/packages/webpage-client/src/pages/api/campaigns/[widget_id].ts index 461146bca..0001d01da 100644 --- a/clients/packages/webpage-client/src/pages/api/campaigns/[widget_id].ts +++ b/clients/packages/webpage-client/src/pages/api/campaigns/[widget_id].ts @@ -8,12 +8,9 @@ interface Request { } const { - publicRuntimeConfig: { - openApiUrl, - openApiToken, - openApiCampaignId - } -} = getConfig() + publicRuntimeConfig: { openApiUrl, openApiCampaignId }, + serverRuntimeConfig: { openApiToken } +} = getConfig(); const campaign_id = openApiCampaignId; diff --git a/clients/packages/webpage-client/src/pages/api/phone/[widget_id]/create.ts b/clients/packages/webpage-client/src/pages/api/phone/[widget_id]/create.ts index a3477cc79..4ab3f8cbf 100644 --- a/clients/packages/webpage-client/src/pages/api/phone/[widget_id]/create.ts +++ b/clients/packages/webpage-client/src/pages/api/phone/[widget_id]/create.ts @@ -15,12 +15,9 @@ interface Request { } const { - publicRuntimeConfig: { - openApiUrl, - openApiToken, - openApiCampaignId - } -} = getConfig() + publicRuntimeConfig: { openApiUrl, openApiCampaignId }, + serverRuntimeConfig: { openApiToken } +} = getConfig(); const campaign_id = openApiCampaignId;