Skip to content

Commit

Permalink
Allow additional headers (#669)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Breederveld and Chris Breederveld authored Nov 30, 2024
1 parent b9b7785 commit b99c53b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/MiniProfiler.Shared/ui/lib/MiniProfiler.ts
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ namespace StackExchange.Profiling {
toggleShortcut: string;
trivialMilliseconds: number;
version: string;
additionalHeaders: object;
}

enum RenderMode {
Expand Down Expand Up @@ -302,6 +303,7 @@ namespace StackExchange.Profiling {
startHidden: bool(data.startHidden),
ignoredDuplicateExecuteTypes: (data.ignoredDuplicateExecuteTypes || '').split(','),
nonce: script.nonce,
additionalHeaders: {},
};

function doInit() {
Expand Down Expand Up @@ -465,8 +467,9 @@ namespace StackExchange.Profiling {
method: 'POST',
body: JSON.stringify(request),
headers: {
...(this.options.additionalHeaders ?? {}),
'Accept': 'application/json',
'Content-Type': 'application/json'
'Content-Type': 'application/json',
}
})
.then(data => data.text())
Expand Down

0 comments on commit b99c53b

Please sign in to comment.