Skip to content

Commit b99c53b

Browse files
BreederveldChris Breederveld
and
Chris Breederveld
authored
Allow additional headers (#669)
Allow the client code to provide additional headers for custom implementations. Specifically the goal for us is to be able to include authentication using a bearer token, but this solution should cover other custom cases as well. Co-authored-by: Chris Breederveld <[email protected]>
1 parent b9b7785 commit b99c53b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts

100644100755
+4-1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ namespace StackExchange.Profiling {
122122
toggleShortcut: string;
123123
trivialMilliseconds: number;
124124
version: string;
125+
additionalHeaders: object;
125126
}
126127

127128
enum RenderMode {
@@ -302,6 +303,7 @@ namespace StackExchange.Profiling {
302303
startHidden: bool(data.startHidden),
303304
ignoredDuplicateExecuteTypes: (data.ignoredDuplicateExecuteTypes || '').split(','),
304305
nonce: script.nonce,
306+
additionalHeaders: {},
305307
};
306308

307309
function doInit() {
@@ -465,8 +467,9 @@ namespace StackExchange.Profiling {
465467
method: 'POST',
466468
body: JSON.stringify(request),
467469
headers: {
470+
...(this.options.additionalHeaders ?? {}),
468471
'Accept': 'application/json',
469-
'Content-Type': 'application/json'
472+
'Content-Type': 'application/json',
470473
}
471474
})
472475
.then(data => data.text())

0 commit comments

Comments
 (0)