diff --git a/.changeset/nervous-tips-pay.md b/.changeset/nervous-tips-pay.md new file mode 100644 index 00000000000..76495ab55c4 --- /dev/null +++ b/.changeset/nervous-tips-pay.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +fix: allow account linking on thirdweb dashboard diff --git a/packages/thirdweb/src/utils/fetch.ts b/packages/thirdweb/src/utils/fetch.ts index 7dbb15521ec..15df8d3f308 100644 --- a/packages/thirdweb/src/utils/fetch.ts +++ b/packages/thirdweb/src/utils/fetch.ts @@ -47,7 +47,7 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) { // if we have an auth token set, use that (thirdweb.com/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" - if (authToken && !isPayUrl(url)) { + if (authToken && !isPayUrl(url) && !isInAppWalletUrl(url)) { headers.set("authorization", `Bearer ${authToken}`); } else if (secretKey) { headers.set("x-secret-key", secretKey); @@ -140,6 +140,19 @@ function isPayUrl(url: string): boolean { } } +function isInAppWalletUrl(url: string): boolean { + try { + const { hostname } = new URL(url); + // in app wallet service hostname always starts with "in-app-wallet." or "embedded-wallet." + return ( + hostname.startsWith("in-app-wallet.") || + hostname.startsWith("embedded-wallet.") + ); + } catch { + return false; + } +} + const SDK_NAME = "unified-sdk"; let previousPlatform: [string, string][] | undefined;