From aba8feb98507cd763ac438c69cf3dd00f5a39c47 Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Wed, 8 Feb 2023 01:28:46 +0700 Subject: [PATCH] Patch encoding header issue for some integrations for getting their apps --- backend/src/integrations/apps.ts | 9 +++++++-- backend/src/integrations/exchange.ts | 3 ++- frontend/src/pages/integrations/[id].tsx | 2 +- .../src/pages/integrations/github/oauth2/callback.tsx | 1 - 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/backend/src/integrations/apps.ts b/backend/src/integrations/apps.ts index 50f146be57..3d834d8768 100644 --- a/backend/src/integrations/apps.ts +++ b/backend/src/integrations/apps.ts @@ -262,7 +262,9 @@ const getAppsRender = async ({ const res = ( await axios.get(`${INTEGRATION_RENDER_API_URL}/v1/services`, { headers: { - Authorization: `Bearer ${accessToken}` + Authorization: `Bearer ${accessToken}`, + Accept: 'application/json', + 'Accept-Encoding': 'application/json' } }) ).data; @@ -272,6 +274,7 @@ const getAppsRender = async ({ name: a.service.name, appId: a.service.id })); + } catch (err) { Sentry.setUser(null); Sentry.captureException(err); @@ -311,7 +314,9 @@ const getAppsFlyio = async ({ url: INTEGRATION_FLYIO_API_URL, method: 'post', headers: { - 'Authorization': 'Bearer ' + accessToken + 'Authorization': 'Bearer ' + accessToken, + 'Accept': 'application/json', + 'Accept-Encoding': 'application/json' }, data: { query, diff --git a/backend/src/integrations/exchange.ts b/backend/src/integrations/exchange.ts index 846c9e7db9..8650b31a09 100644 --- a/backend/src/integrations/exchange.ts +++ b/backend/src/integrations/exchange.ts @@ -322,7 +322,8 @@ const exchangeCodeGithub = async ({ code }: { code: string }) => { redirect_uri: `${SITE_URL}/integrations/github/oauth2/callback` }, headers: { - Accept: 'application/json' + 'Accept': 'application/json', + 'Accept-Encoding': 'application/json' } }) ).data; diff --git a/frontend/src/pages/integrations/[id].tsx b/frontend/src/pages/integrations/[id].tsx index e6bc784f67..d802e81a8d 100644 --- a/frontend/src/pages/integrations/[id].tsx +++ b/frontend/src/pages/integrations/[id].tsx @@ -253,7 +253,7 @@ export default function Integrations() { const integrationOptionPress = async (integrationOption: IntegrationOption) => { try { const integrationAuthX = integrationAuths.find((integrationAuth) => integrationAuth.integration === integrationOption.slug); - + if (!bot.isActive) { await handleBotActivate(); } diff --git a/frontend/src/pages/integrations/github/oauth2/callback.tsx b/frontend/src/pages/integrations/github/oauth2/callback.tsx index ab2bb18c8f..a3fd7e84c0 100644 --- a/frontend/src/pages/integrations/github/oauth2/callback.tsx +++ b/frontend/src/pages/integrations/github/oauth2/callback.tsx @@ -7,7 +7,6 @@ import AuthorizeIntegration from "../../../api/integrations/authorizeIntegration export default function GitHubOAuth2CallbackPage() { const router = useRouter(); - const { code, state } = queryString.parse(router.asPath.split('?')[1]); useEffect(() => {