Skip to content

Commit 939d557

Browse files
authored
Merge pull request #154 from digma-ai/custom-header
Added custom header
2 parents 0a9816d + d41906d commit 939d557

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@
116116
},
117117
"digma.token": {
118118
"type": "string"
119+
},
120+
"digma.customHeader": {
121+
"type": "string",
122+
"description": "Specify a custom header to requests sent to Digma server. Useful in case Digma is deployed behind an ingress component, and need be routed (Example: \"Host:digma.loremipsum.com\")."
119123
}
120124
}
121125
}

src/services/analyticsProvider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,10 @@ export class AnalyticsProvider
546546
if(Settings.token.value !== undefined && Settings.token.value.trim() !== ""){
547547
requestHeaders['Authorization'] = `Token ${Settings.token.value}`;
548548
}
549-
549+
let customHeaderMatch = new RegExp(`^ *([^ ]+) *: *(.+[^ ]) *$`).exec(Settings.customHeader.value ?? '');
550+
if(customHeaderMatch){
551+
requestHeaders[customHeaderMatch[1]] = customHeaderMatch[2];
552+
}
550553

551554
let response = await fetch(
552555
url,

src/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ export class Settings
4545

4646
public static readonly token = new SettingsKey('token', '');
4747

48+
public static readonly customHeader = new SettingsKey('customHeader', '');
49+
4850
}

0 commit comments

Comments
 (0)