Skip to content

Commit e739de1

Browse files
committed
Only set secret key or client ID when not using auth token (#6994)
This PR modifies the header setting logic in `getClientFetch` to ensure that secret keys and client IDs are only set when not using an auth token. This prevents potential conflicts between different authentication methods by making the header setting logic mutually exclusive. <!-- start pr-codex --> --- ## PR-Codex overview This PR modifies the logic in the `fetch.ts` file to ensure that the `x-secret-key` and `x-client-id` headers are only set when not using the authentication token, enhancing security and clarity in header management. ### Detailed summary - Added an `else` clause to only set `x-secret-key` if not using the auth token. - Rearranged the condition for setting `x-client-id` to follow the new logic. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 451594c commit e739de1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/thirdweb/src/utils/fetch.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) {
7070
if (client.teamId) {
7171
headers.set("x-team-id", client.teamId);
7272
}
73-
}
74-
75-
if (secretKey) {
76-
headers.set("x-secret-key", secretKey);
77-
}
73+
} else {
74+
// only set secret key or client id if we are NOT using the auth token!
75+
if (secretKey) {
76+
headers.set("x-secret-key", secretKey);
77+
}
7878

79-
if (clientId) {
80-
headers.set("x-client-id", clientId);
79+
if (clientId) {
80+
headers.set("x-client-id", clientId);
81+
}
8182
}
8283

8384
if (ecosystem) {

0 commit comments

Comments
 (0)