Skip to content

Commit

Permalink
fix: remove auth headers passed to fetchUpload
Browse files Browse the repository at this point in the history
  • Loading branch information
onehassan committed May 9, 2024
1 parent 87f1986 commit 22ecafe
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .changeset/spicy-trains-trade.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
'@nhost/hasura-storage-js': patch
'@nhost/graphql-js': patch
'@nhost/nhost-js': patch
'@nhost/hasura-storage-js': minor
'@nhost/graphql-js': minor
'@nhost/nhost-js': minor
---

feat: add `setHeaders` method enabling global configuration of storage, graphql, and functions client headers, alongside added support for passing specific headers with individual calls
2 changes: 1 addition & 1 deletion packages/graphql-js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class NhostGraphqlClient {
* @example
* ```ts
* nhost.graphql.setHeaders({
* 'x-hasura-role'
* 'x-hasura-role': 'admin'
* })
* ```
*
Expand Down
11 changes: 5 additions & 6 deletions packages/hasura-storage-js/src/hasura-storage-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export class HasuraStorageApi {
const { error, fileMetadata } = await fetchUpload(this.url, formData, {
bucketId,
headers: {
...this.generateAuthHeaders(),
...this.headers, // global nhost storage client headers to be sent with all `uploadFormData` calls
...extraHeaders // extra headers to be sent with a specific call
},
Expand Down Expand Up @@ -87,8 +86,8 @@ export class HasuraStorageApi {
fileId: id,
name,
headers: {
...this.headers,
...extraHeaders // global nhost storage client headers to be sent with all `uploadFile` calls
...this.headers, // global nhost storage client headers to be sent with all `uploadFile` calls
...extraHeaders // extra headers to be sent with a specific call
}
})

Expand Down Expand Up @@ -120,7 +119,7 @@ export class HasuraStorageApi {
headers: {
...this.generateAuthHeaders(),
...this.headers, // global nhost storage client headers to be sent with all `downloadFile` calls
...extraHeaders
...extraHeaders // extra headers to be sent with a specific call
}
})

Expand All @@ -145,7 +144,7 @@ export class HasuraStorageApi {
headers: {
...this.generateAuthHeaders(),
...this.headers, // global nhost storage client headers to be sent with all `getPresignedUrl` calls
...extraHeaders
...extraHeaders // extra headers to be sent with a specific call
}
})
if (!response.ok) {
Expand All @@ -166,7 +165,7 @@ export class HasuraStorageApi {
headers: {
...this.generateAuthHeaders(),
...this.headers, // global nhost storage client headers to be sent with all `delete` calls
...extraHeaders
...extraHeaders // extra headers to be sent with a specific call
}
})
if (!response.ok) {
Expand Down
2 changes: 1 addition & 1 deletion packages/hasura-storage-js/src/hasura-storage-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class HasuraStorageClient {
* @example
* ```ts
* nhost.storage.setHeaders({
* "x-hasura-role": "admin"
* 'x-hasura-role': 'admin'
* })
* ```
*
Expand Down

0 comments on commit 22ecafe

Please sign in to comment.