Skip to content

Commit 91d6d07

Browse files
Merge pull request #914 from devtron-labs/feat/proxy-host
feat: proxy host
2 parents 569bdf8 + cc6296d commit 91d6d07

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.20.3-pre-10",
3+
"version": "1.20.3-pre-11",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/API/CoreAPI.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class CoreAPI {
4949
preventLicenseRedirect = false,
5050
shouldParseServerErrorForUnauthorizedUser = false,
5151
isMultipartRequest,
52+
isProxyHost = false,
5253
}: FetchAPIParamsType<K>): Promise<ResponseType> => {
5354
const options: RequestInit = {
5455
method: type,
@@ -58,7 +59,7 @@ class CoreAPI {
5859
// eslint-disable-next-line dot-notation
5960
options['credentials'] = 'include' as RequestCredentials
6061
return fetch(
61-
`${this.host}/${url}`,
62+
`${isProxyHost ? '/proxy' : this.host}/${url}`,
6263
!isMultipartRequest
6364
? options
6465
: ({

src/Common/API/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,10 @@ export interface FetchInTimeParamsType<Data = object> {
4040
export interface FetchAPIParamsType<Data = object>
4141
extends Omit<FetchInTimeParamsType<Data>, 'options'>,
4242
Pick<APIOptions, 'preventAutoLogout' | 'preventLicenseRedirect' | 'shouldParseServerErrorForUnauthorizedUser'> {
43+
/**
44+
* @default false
45+
* @description - If true, will override the default host (orchestrator or whatever defined initially in CoreAPI constructor) with the `proxy` host
46+
*/
47+
isProxyHost?: boolean
4348
signal: AbortSignal
4449
}

0 commit comments

Comments
 (0)