Skip to content

Commit a8638b0

Browse files
authored
chore(backend): Use Headers constructor when building BAPI client headers (#6235)
1 parent da2c741 commit a8638b0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.changeset/tasty-starfishes-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clerk/backend": patch
3+
---
4+
5+
Use Headers constructor when building BAPI client headers

packages/backend/src/api/request.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ export function buildRequest(options: BuildRequestOptions) {
102102
}
103103

104104
// Build headers
105-
const headers: Record<string, any> = {
105+
const headers = new Headers({
106106
'Clerk-API-Version': SUPPORTED_BAPI_VERSION,
107107
'User-Agent': userAgent,
108108
...headerParams,
109-
};
109+
});
110110

111111
if (secretKey) {
112-
headers.Authorization = `Bearer ${secretKey}`;
112+
headers.set('Authorization', `Bearer ${secretKey}`);
113113
}
114114

115115
let res: Response | undefined;
@@ -122,7 +122,7 @@ export function buildRequest(options: BuildRequestOptions) {
122122
});
123123
} else {
124124
// Enforce application/json for all non form-data requests
125-
headers['Content-Type'] = 'application/json';
125+
headers.set('Content-Type', 'application/json');
126126

127127
const buildBody = () => {
128128
const hasBody = method !== 'GET' && bodyParams && Object.keys(bodyParams).length > 0;

0 commit comments

Comments
 (0)