Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit d8ca5fc

Browse files
committed
🔧Fix #28
- add "host" header from endpoint in HttpClient
1 parent 620a7df commit d8ca5fc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

services/HttpClient.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class HttpClient {
7171
this.endPoint = options.hasOwnProperty('endPoint')
7272
? options.endPoint
7373
: defaultEndpoint;
74+
const parsedUrl = new URL(this.endPoint);
75+
this.endPointHost = parsedUrl.host;
7476
this.options = options;
7577
this.got = got.extend(
7678
Object.assign(
@@ -254,12 +256,13 @@ class HttpClient {
254256
* @param options - custom options
255257
* @return {object} final request options
256258
*/
257-
_finalizeRequestOptions(options = {}) {
259+
_finalizeRequestOptions(options = { headers: {} }) {
258260
let optionPrefix = options.prefix || this.options.prefix;
259261
// TODO: a path rewrite could be better
260262
if (isCustomAPIPrefix && optionPrefix) {
261263
options.url = options.url.replace(new RegExp(`^${optionPrefix}`), '');
262264
}
265+
options.headers.host = this.endPointHost;
263266
return options;
264267
}
265268

0 commit comments

Comments
 (0)