From 558b91896f4800a4d83b4d4cd2366cb44439f09a Mon Sep 17 00:00:00 2001 From: Maher Khalil Date: Mon, 3 Mar 2025 13:25:52 -0500 Subject: [PATCH 1/2] fix(client): proper encoding such that [ get encoded instead of interpreted as arrays --- packages/client/src/stores/monolith/monolith.store.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/client/src/stores/monolith/monolith.store.ts b/packages/client/src/stores/monolith/monolith.store.ts index c811c07b4f..9472102fea 100644 --- a/packages/client/src/stores/monolith/monolith.store.ts +++ b/packages/client/src/stores/monolith/monolith.store.ts @@ -2676,6 +2676,16 @@ export class MonolithStore { offset: offset, limit: limit, }, + paramsSerializer: (params) => { + return Object.keys(params) + .map( + (key) => + `${encodeURIComponent( + key, + )}=${encodeURIComponent(params[key])}`, + ) + .join('&'); + }, }) .catch((error) => { throw Error(error); From e0f8b72d43e12ca3eca56c4e685177fa34254957 Mon Sep 17 00:00:00 2001 From: Maher Khalil Date: Mon, 3 Mar 2025 13:54:10 -0500 Subject: [PATCH 2/2] fix(client): moving logic to interceptor for all GET requests --- packages/client/src/App.tsx | 23 +++++++++++++++++++ .../src/stores/monolith/monolith.store.ts | 10 -------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/packages/client/src/App.tsx b/packages/client/src/App.tsx index 6317ef7327..48889a3701 100644 --- a/packages/client/src/App.tsx +++ b/packages/client/src/App.tsx @@ -6,6 +6,29 @@ import { RootStoreContext } from '@/contexts'; import { AppWrapper } from './AppWrapper'; // add interceptors +axios.interceptors.request.use( + (config) => { + // Check if the request is a GET request + if (config.method === 'get' && config.params) { + config.paramsSerializer = (params) => { + return Object.keys(params) + .map( + (key) => + `${encodeURIComponent(key)}=${encodeURIComponent( + params[key], + )}`, + ) + .join('&'); + }; + } + return config; + }, + (error) => { + // Handle request error + return Promise.reject(error); + }, +); + axios.interceptors.response.use( function (response) { return response; diff --git a/packages/client/src/stores/monolith/monolith.store.ts b/packages/client/src/stores/monolith/monolith.store.ts index 9472102fea..c811c07b4f 100644 --- a/packages/client/src/stores/monolith/monolith.store.ts +++ b/packages/client/src/stores/monolith/monolith.store.ts @@ -2676,16 +2676,6 @@ export class MonolithStore { offset: offset, limit: limit, }, - paramsSerializer: (params) => { - return Object.keys(params) - .map( - (key) => - `${encodeURIComponent( - key, - )}=${encodeURIComponent(params[key])}`, - ) - .join('&'); - }, }) .catch((error) => { throw Error(error);