Skip to content

Commit 9663fc7

Browse files
committed
chore: don't override auth token / client id when hitting in app wallet url
1 parent 0c5b0bf commit 9663fc7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/thirdweb/src/utils/fetch.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) {
4747

4848
// if we have an auth token set, use that (thirdweb.com/dashboard sets this for the user)
4949
// 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"
50-
if (authToken && !isPayUrl(url)) {
50+
if (authToken && !isPayUrl(url) && !isInAppWalletUrl(url)) {
5151
headers.set("authorization", `Bearer ${authToken}`);
5252
} else if (secretKey) {
5353
headers.set("x-secret-key", secretKey);
@@ -140,6 +140,19 @@ function isPayUrl(url: string): boolean {
140140
}
141141
}
142142

143+
function isInAppWalletUrl(url: string): boolean {
144+
try {
145+
const { hostname } = new URL(url);
146+
// pay service hostname always starts with "pay."
147+
return (
148+
hostname.startsWith("in-app-wallet.") ||
149+
hostname.startsWith("embedded-wallet.")
150+
);
151+
} catch {
152+
return false;
153+
}
154+
}
155+
143156
const SDK_NAME = "unified-sdk";
144157

145158
let previousPlatform: [string, string][] | undefined;

0 commit comments

Comments
 (0)