Skip to content

Commit aca5a58

Browse files
committed
fix: add condition for if portRequired then port must not be empty or undefined
1 parent ee82c27 commit aca5a58

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

middleserver/controllers/middlemanController.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,16 @@ const MiddlemanController = async (req, res) => {
7272
}
7373

7474
const { host, port, method, params, protocol, portRequired } = jsonresponse.data || {};
75-
if (!host || !port) {
75+
if (!host) {
7676
logError("Registry returned invalid server info", jsonresponse);
7777
return res.status(500).json(new ApiResponse(500, "Invalid server info from registry"));
7878
}
7979

80+
if (portRequired && !port){
81+
logError("Port Required but not provided by registry", jsonresponse);
82+
return res.status(500).json(new ApiResponse(500, "Port required but not provided by registry"));
83+
}
84+
8085
if (showLog) {
8186
logInfo("Sending request to Server", { host, port, method, params });
8287
}
@@ -100,7 +105,7 @@ const MiddlemanController = async (req, res) => {
100105
jsonresponsee = await serverResponse.json();
101106

102107
} else {
103-
serverResponse = await fetch(`${protocol}://${host}/api/v1/${method}`, {
108+
serverResponse = await fetch(`${protocol}://${host}/api/v1/ndk-load-balancer/forward-requests`, {
104109
method: "POST",
105110
headers: { "Content-Type": "application/json" },
106111
body: JSON.stringify({ method, params }),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ndk-rpc-cluster",
3-
"version": "1.0.8",
3+
"version": "2.0.0",
44
"description": "Enterprise-grade RPC cluster system with load balancing, fault tolerance, service discovery and automatic failover support",
55
"type": "module",
66
"main": "./index.mjs",

0 commit comments

Comments
 (0)