@@ -24,6 +24,9 @@ export class HttpClient {
2424 // Server PORT
2525 public port : number | string = process . env . PORT ;
2626
27+ // Global headers
28+ public headers ?: Object ;
29+
2730 /**
2831 * Send a POST http request to the server
2932 * @param path Path to send to (e.g. /users)
@@ -48,6 +51,10 @@ export class HttpClient {
4851 if ( bearer ) {
4952 options [ 'auth' ] = { bearer : `${ bearer } ` } ;
5053 }
54+
55+ if ( this . headers ) {
56+ options [ 'headers' ] = this . headers ;
57+ }
5158
5259 return new Promise < HttpClientResponse > ( ( accept , reject ) => {
5360 this . request ( options , ( error , response , body ) => {
@@ -94,6 +101,10 @@ export class HttpClient {
94101 if ( bearer ) {
95102 options [ 'auth' ] = { bearer : `${ bearer } ` } ;
96103 }
104+
105+ if ( this . headers ) {
106+ options [ 'headers' ] = this . headers ;
107+ }
97108
98109 this . request ( options , ( error , response , body ) => {
99110 if ( error ) {
@@ -138,6 +149,10 @@ export class HttpClient {
138149 if ( bearer ) {
139150 options [ 'auth' ] = { bearer : `${ bearer } ` } ;
140151 }
152+
153+ if ( this . headers ) {
154+ options [ 'headers' ] = this . headers ;
155+ }
141156
142157 return new Promise < HttpClientResponse > ( ( accept , reject ) => {
143158 this . request ( options , ( error , response , body ) => {
@@ -181,6 +196,10 @@ export class HttpClient {
181196 if ( bearer ) {
182197 options [ 'auth' ] = { bearer : `${ bearer } ` } ;
183198 }
199+
200+ if ( this . headers ) {
201+ options [ 'headers' ] = this . headers ;
202+ }
184203
185204 this . request ( options , ( error , response , body ) => {
186205 if ( error ) {
0 commit comments