Skip to content

Commit 7dc84d3

Browse files
committed
Force auth token usage for storage uploads
1 parent c81fed3 commit 7dc84d3

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/thirdweb/src/storage/upload/web-node.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export async function uploadBatch<const TFiles extends UploadableFile[]>(
2525
body: form,
2626
requestTimeoutMs:
2727
client.config?.storage?.fetch?.requestTimeoutMs || 120000,
28+
// force auth token usage for storage uploads
29+
useAuthToken: true,
2830
},
2931
);
3032

packages/thirdweb/src/utils/fetch.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) {
2222
*/
2323
async function fetchWithHeaders(
2424
url: string | Request,
25-
init?: Omit<RequestInit, "signal"> & { requestTimeoutMs?: number },
25+
init?: Omit<RequestInit, "signal"> & {
26+
requestTimeoutMs?: number;
27+
useAuthToken?: boolean;
28+
},
2629
): Promise<Response> {
27-
const { requestTimeoutMs = DEFAULT_REQUEST_TIMEOUT, ...restInit } =
28-
init || {};
30+
const {
31+
requestTimeoutMs = DEFAULT_REQUEST_TIMEOUT,
32+
useAuthToken,
33+
...restInit
34+
} = init || {};
2935

3036
let headers = restInit.headers
3137
? new Headers(restInit.headers)
@@ -41,7 +47,7 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) {
4147
}
4248
// auth token if secret key === jwt
4349
const authToken =
44-
client.secretKey && isJWT(client.secretKey)
50+
useAuthToken && client.secretKey && isJWT(client.secretKey)
4551
? client.secretKey
4652
: undefined;
4753
// secret key if secret key !== jwt

0 commit comments

Comments
 (0)