@tramvai/tinkoff-request-http-client-adapter 0.14.74 → 0.14.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -52,7 +52,8 @@ function createTinkoffRequest(options) {
|
|
|
52
52
|
}
|
|
53
53
|
if (process.env.NODE_ENV === 'development') {
|
|
54
54
|
if (!baseUrl && !path) {
|
|
55
|
-
log?.error(
|
|
55
|
+
log?.error(`Запрос должен содержать url, или baseUrl с полным путем запроса, или baseUrl вместе с path.
|
|
56
|
+
Если вы передаете baseUrlEnv, значит указанная переменная окружения не задана или пуста.`);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
return baseUrl || path || '';
|
|
@@ -52,7 +52,8 @@ function createTinkoffRequest(options) {
|
|
|
52
52
|
}
|
|
53
53
|
if (process.env.NODE_ENV === 'development') {
|
|
54
54
|
if (!baseUrl && !path) {
|
|
55
|
-
log?.error(
|
|
55
|
+
log?.error(`Запрос должен содержать url, или baseUrl с полным путем запроса, или baseUrl вместе с path.
|
|
56
|
+
Если вы передаете baseUrlEnv, значит указанная переменная окружения не задана или пуста.`);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
return baseUrl || path || '';
|
|
@@ -70,7 +70,8 @@ function createTinkoffRequest(options) {
|
|
|
70
70
|
}
|
|
71
71
|
if (process.env.NODE_ENV === 'development') {
|
|
72
72
|
if (!baseUrl && !path) {
|
|
73
|
-
log?.error(
|
|
73
|
+
log?.error(`Запрос должен содержать url, или baseUrl с полным путем запроса, или baseUrl вместе с path.
|
|
74
|
+
Если вы передаете baseUrlEnv, значит указанная переменная окружения не задана или пуста.`);
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
return baseUrl || path || '';
|
|
@@ -11,7 +11,16 @@ class HttpClientAdapter extends BaseHttpClient {
|
|
|
11
11
|
this.makeRequest = makeRequest;
|
|
12
12
|
}
|
|
13
13
|
request(req) {
|
|
14
|
-
//
|
|
14
|
+
// prevent CORS error when trying to set custom header in browser
|
|
15
|
+
if (typeof window !== 'undefined') {
|
|
16
|
+
if (this.options.headers?.['x-tramvai-service-name']) {
|
|
17
|
+
delete this.options.headers['x-tramvai-service-name'];
|
|
18
|
+
}
|
|
19
|
+
if (req.headers?.['x-tramvai-service-name']) {
|
|
20
|
+
delete req.headers['x-tramvai-service-name'];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// apply default options before calling modifyRequest on the request object
|
|
15
24
|
const optionsWithDefaults = mergeOptions(this.options, req);
|
|
16
25
|
const { modifyRequest, modifyResponse, modifyError, interceptors, ...reqWithDefaults } = optionsWithDefaults;
|
|
17
26
|
let _next = (_req) => this._processMakeRequest(_req, { modifyRequest, modifyResponse, modifyError });
|
|
@@ -11,7 +11,16 @@ class HttpClientAdapter extends BaseHttpClient {
|
|
|
11
11
|
this.makeRequest = makeRequest;
|
|
12
12
|
}
|
|
13
13
|
request(req) {
|
|
14
|
-
//
|
|
14
|
+
// prevent CORS error when trying to set custom header in browser
|
|
15
|
+
if (typeof window !== 'undefined') {
|
|
16
|
+
if (this.options.headers?.['x-tramvai-service-name']) {
|
|
17
|
+
delete this.options.headers['x-tramvai-service-name'];
|
|
18
|
+
}
|
|
19
|
+
if (req.headers?.['x-tramvai-service-name']) {
|
|
20
|
+
delete req.headers['x-tramvai-service-name'];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// apply default options before calling modifyRequest on the request object
|
|
15
24
|
const optionsWithDefaults = mergeOptions(this.options, req);
|
|
16
25
|
const { modifyRequest, modifyResponse, modifyError, interceptors, ...reqWithDefaults } = optionsWithDefaults;
|
|
17
26
|
let _next = (_req) => this._processMakeRequest(_req, { modifyRequest, modifyResponse, modifyError });
|
package/lib/httpClientAdapter.js
CHANGED
|
@@ -15,7 +15,16 @@ class HttpClientAdapter extends httpClient.BaseHttpClient {
|
|
|
15
15
|
this.makeRequest = makeRequest;
|
|
16
16
|
}
|
|
17
17
|
request(req) {
|
|
18
|
-
//
|
|
18
|
+
// prevent CORS error when trying to set custom header in browser
|
|
19
|
+
if (typeof window !== 'undefined') {
|
|
20
|
+
if (this.options.headers?.['x-tramvai-service-name']) {
|
|
21
|
+
delete this.options.headers['x-tramvai-service-name'];
|
|
22
|
+
}
|
|
23
|
+
if (req.headers?.['x-tramvai-service-name']) {
|
|
24
|
+
delete req.headers['x-tramvai-service-name'];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// apply default options before calling modifyRequest on the request object
|
|
19
28
|
const optionsWithDefaults = mergeOptions.mergeOptions(this.options, req);
|
|
20
29
|
const { modifyRequest, modifyResponse, modifyError, interceptors, ...reqWithDefaults } = optionsWithDefaults;
|
|
21
30
|
let _next = (_req) => this._processMakeRequest(_req, { modifyRequest, modifyResponse, modifyError });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/tinkoff-request-http-client-adapter",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.107",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"@tinkoff/request-plugin-circuit-breaker": "^0.5.0",
|
|
30
30
|
"@tinkoff/request-plugin-log": "^0.10.0",
|
|
31
31
|
"@tinkoff/request-plugin-protocol-http": "0.16.0",
|
|
32
|
-
"@tinkoff/request-plugin-retry": "^0.3.
|
|
32
|
+
"@tinkoff/request-plugin-retry": "^0.3.1",
|
|
33
33
|
"@tinkoff/request-plugin-transform-url": "^0.10.0",
|
|
34
34
|
"@tinkoff/request-plugin-validate": "^0.10.0",
|
|
35
35
|
"@tinkoff/utils": "^2.1.2",
|
|
36
36
|
"@tramvai/http-client": "0.7.1",
|
|
37
|
-
"@tramvai/tokens-common": "7.
|
|
37
|
+
"@tramvai/tokens-common": "7.26.9",
|
|
38
38
|
"tslib": "^2.4.0",
|
|
39
39
|
"undici": "^7.24.4"
|
|
40
40
|
},
|