The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix the callback
Kiran Ka37622223dbb
diff --git a/apps/web/app/(ee)/api/hubspot/callback/route.ts b/apps/web/app/(ee)/api/hubspot/callback/route.tsindex c307ae6381..393d26ce66 100644--- a/apps/web/app/(ee)/api/hubspot/callback/route.ts+++ b/apps/web/app/(ee)/api/hubspot/callback/route.ts@@ -4,8 +4,10 @@ import {HUBSPOT_CLIENT_ID,HUBSPOT_CLIENT_SECRET,HUBSPOT_REDIRECT_URI,+ HUBSPOT_STATE_CACHE_PREFIX,} from "@/lib/integrations/hubspot/constants";import { installIntegration } from "@/lib/integrations/install";+import { redis } from "@/lib/upstash";import z from "@/lib/zod";import { prisma } from "@dub/prisma";import { Project } from "@dub/prisma/client";@@ -46,19 +48,17 @@ export const GET = async (req: Request) => {const { code, state } = oAuthCallbackSchema.parse(getSearchParams(req.url));- // // Find workspace that initiated the Stripe app install- // const workspaceId = await redis.get<string>(- // `hubspot:install:state:${state}`,- // );-- // if (!workspaceId) {- // throw new DubApiError({- // code: "bad_request",- // message: "Unknown state. Please try again.",- // });- // }+ // Find workspace that initiated the install+ const workspaceId = await redis.get<string>(+ `${HUBSPOT_STATE_CACHE_PREFIX}:${state}`,+ );- const workspaceId = "clrei1gld0002vs9mzn93p8ik";+ if (!workspaceId) {+ throw new DubApiError({+ code: "bad_request",+ message: "Unknown state. Please try again.",+ });+ }workspace = await prisma.project.findUniqueOrThrow({where: {@@ -97,8 +97,6 @@ export const GET = async (req: Request) => {},});- console.log(credentials);-// Install the integrationawait installIntegration({integrationId: integration.id,diff --git a/apps/web/lib/integrations/hubspot/install.ts b/apps/web/lib/integrations/hubspot/install.tsindex 4a6ca3622e..5be0418f2e 100644--- a/apps/web/lib/integrations/hubspot/install.ts+++ b/apps/web/lib/integrations/hubspot/install.ts@@ -18,7 +18,7 @@ export const getHubSpotInstallationUrl = async (workspaceId: string) => {state,});- await redis.set(`${HUBSPOT_STATE_CACHE_PREFIX}${state}`, workspaceId, {+ await redis.set(`${HUBSPOT_STATE_CACHE_PREFIX}:${state}`, workspaceId, {ex: 30 * 60,});