Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server host resolving issue in rule get resources api #7450

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/many-kiwis-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/admin.rules.v1": patch
---

Fix server Host resolving issue in rule get resources api
4 changes: 2 additions & 2 deletions features/admin.rules.v1/api/use-get-resource-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
* under the License.
*/

import { Config } from "@wso2is/admin.core.v1/configs/app";
import useRequest, {
RequestConfigInterface,
RequestErrorInterface,
RequestResultInterface
} from "@wso2is/admin.core.v1/hooks/use-request";
import { store } from "@wso2is/admin.core.v1/store";
import { HttpMethods } from "@wso2is/core/models";

/**
Expand All @@ -44,7 +44,7 @@ const useGetResourcesList = <Data = any, Error = RequestErrorInterface>(
"Content-Type": "application/json"
},
method: HttpMethods.GET,
url: store.getState().config.deployment.idpConfigs.serverOrigin + `/api/server/v1${endpointPath}`
url: Config.resolveServerHost() + `/api/server/v1${endpointPath}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason we haven't taken these values from the endpoint configuration? Ex:- https://github.com/wso2/identity-apps/blob/master/features/admin.applications.v1/configs/endpoints.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot hard code the path here as this api is designed to invoke any given endpoint. That endpoint path can be vary depends on the scenario.

The api path is resolved from the ruleMeta Api.
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think still we can define the static part in endpoint.ts file. Then you can change the endpoint path dynamically like the following logic.

store.getState().config.endpoints.actions.youendpoint + dynamicEndpoint

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is urgent, let's send the fix now and refactor the code in a separate PR.

};

const { data, error, isLoading, isValidating, mutate } = useRequest<Data, Error>(
Expand Down
4 changes: 2 additions & 2 deletions features/admin.rules.v1/api/use-get-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
* under the License.
*/

import { Config } from "@wso2is/admin.core.v1/configs/app";
import useRequest, {
RequestConfigInterface,
RequestErrorInterface,
RequestResultInterface
} from "@wso2is/admin.core.v1/hooks/use-request";
import { store } from "@wso2is/admin.core.v1/store";
import { HttpMethods } from "@wso2is/core/models";

/**
Expand All @@ -44,7 +44,7 @@ const useGetResourceDetails = <Data = any, Error = RequestErrorInterface>(
"Content-Type": "application/json"
},
method: HttpMethods.GET,
url: store.getState().config.deployment.idpConfigs.serverOrigin + `/api/server/v1${endpointPath}`
url: Config.resolveServerHost() + `/api/server/v1${endpointPath}`
};

const { data, error, isLoading, isValidating, mutate } = useRequest<Data, Error>(
Expand Down
Loading