diff --git a/apps/dashboard/src/@/constants/thirdweb-client.client.ts b/apps/dashboard/src/@/constants/thirdweb-client.client.ts index 428684ca171..3b38795a0e8 100644 --- a/apps/dashboard/src/@/constants/thirdweb-client.client.ts +++ b/apps/dashboard/src/@/constants/thirdweb-client.client.ts @@ -3,9 +3,11 @@ import { getConfiguredThirdwebClient } from "./thirdweb.server"; export function getClientThirdwebClient(params?: { jwt: string | undefined | null; teamId: string | undefined | null; + projectClientId?: string; }) { return getConfiguredThirdwebClient({ secretKey: params?.jwt ?? undefined, teamId: params?.teamId ?? undefined, + projectClientId: params?.projectClientId, }); } diff --git a/apps/dashboard/src/@/constants/thirdweb.server.ts b/apps/dashboard/src/@/constants/thirdweb.server.ts index cd7aab19f8b..033bb7ed7dc 100644 --- a/apps/dashboard/src/@/constants/thirdweb.server.ts +++ b/apps/dashboard/src/@/constants/thirdweb.server.ts @@ -25,6 +25,7 @@ import { getVercelEnv } from "@/utils/vercel"; export function getConfiguredThirdwebClient(options: { secretKey: string | undefined; teamId: string | undefined; + projectClientId: string | undefined; }): ThirdwebClient { if (getVercelEnv() !== "production") { // if not on production: run this when creating a client to set the domains @@ -89,6 +90,7 @@ export function getConfiguredThirdwebClient(options: { }, secretKey: secretKey, teamId: options.teamId, + projectClientId: options.projectClientId, }); } diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/page.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/page.tsx index 555eb0065c5..9328ff3d07f 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/page.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/token/page.tsx @@ -36,7 +36,8 @@ export default async function Page(props: { const client = getClientThirdwebClient({ jwt: authToken, teamId: team.id, - }); + projectClientId: project.publishableKey, + }); return (
diff --git a/packages/thirdweb/src/client/client.ts b/packages/thirdweb/src/client/client.ts index 4c10e25f30f..6bd1186b7d1 100644 --- a/packages/thirdweb/src/client/client.ts +++ b/packages/thirdweb/src/client/client.ts @@ -55,6 +55,12 @@ type ClientOptions = Prettify<{ * @hidden */ teamId?: string; + + /** + * The project client ID for thirdweb dashboard usage. + * @hidden + */ + projectClientId?: string; }>; export type CreateThirdwebClientOptions = Prettify< diff --git a/packages/thirdweb/src/utils/fetch.ts b/packages/thirdweb/src/utils/fetch.ts index e09dcfe80bb..1bec8a4dc16 100644 --- a/packages/thirdweb/src/utils/fetch.ts +++ b/packages/thirdweb/src/utils/fetch.ts @@ -57,15 +57,10 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) { : undefined; const clientId = client.clientId; - if (authToken && isBundlerUrl(urlString)) { + if (authToken && isBundlerUrl(urlString) && client.projectClientId && client.teamId) { headers.set("authorization", `Bearer ${authToken}`); - if (client.teamId) { - headers.set("x-team-id", client.teamId); - } - - if (clientId) { - headers.set("x-client-id", clientId); - } + headers.set("x-team-id", client.teamId); + headers.set("x-client-id", client.projectClientId); } // if we have an auth token set, use that (thirdweb dashboard sets this for the user) // pay urls should never send the auth token, because we always want the "developer" to be the one making the request, not the "end user"