Temp Fix: Add Interceptors for OICP requests
MODIFY
src/client/oicp/OICPClient.ts
src/client/oicp/OICPClient.ts
@@ -40,7 +40,7 @@ export default abstract class OICPClient {
this.oicpEndpoint = oicpEndpoint;
this.role = role.toLowerCase();
this.oicpConfig = Configuration.getOICPServiceConfig();
- this.axiosInstance = AxiosFactory.getAxiosInstance(tenant.id, { axiosConfig: this.getAxiosConfig(ServerAction.OICP_CREATE_AXIOS_INSTANCE) }, true); // FIXME: set noInterceptors = true to avoid 'Converting circular structure to JSON' Error
+ this.axiosInstance = AxiosFactory.getAxiosInstance(tenant.id, { axiosConfig: this.getAxiosConfig(ServerAction.OICP_CREATE_AXIOS_INSTANCE) }); // FIXME: 'Converting circular structure to JSON' Error
}
public getLocalCountryCode(action: ServerAction): string {

MODIFY
src/utils/AxiosFactory.ts
src/utils/AxiosFactory.ts
@@ -14,7 +14,7 @@ export default class AxiosFactory {
private constructor() { }
// All could have been done at 'axios' level normally!
- public static getAxiosInstance(tenantID: string, instanceConfiguration?: { axiosConfig?: AxiosRequestConfig, axiosRetryConfig?: IAxiosRetryConfig }, noInterceptors = false): AxiosInstance {
+ public static getAxiosInstance(tenantID: string, instanceConfiguration?: { axiosConfig?: AxiosRequestConfig, axiosRetryConfig?: IAxiosRetryConfig }): AxiosInstance {
if (!instanceConfiguration) {
instanceConfiguration = {};
}
@@ -33,8 +33,8 @@ export default class AxiosFactory {
// FIXME
// Error Message: Converting circular structure to JSON
- // Temporary FIX: Add no inceptors
- if (!noInterceptors) {
+ // Temporary FIX: Utils.cloneObject() removed
+
// Add a Request interceptor
axiosInstance.interceptors.request.use((request: AxiosRequestConfig) => {
Logging.logAxiosRequest(tenantID, request);
@@ -55,7 +55,6 @@ export default class AxiosFactory {
Logging.logAxiosError(tenantID, error);
return Promise.reject(error);
});
- }
// Add
this.axiosInstances.set(tenantID, axiosInstance);
}

MODIFY
src/utils/Logging.ts
src/utils/Logging.ts
@@ -339,6 +339,7 @@ export default class Logging {
console.warn('====================================');
}
}
+ try {
Logging.logSecurityDebug({
tenantID: tenantID,
action: ServerAction.HTTP_RESPONSE,
@@ -352,6 +353,21 @@ export default class Logging {
response: Utils.cloneObject(response.data)
}
});
+ } catch (error) {
+ // FIXME
+ // Error Message: Converting circular structure to JSON
+ // Temporary FIX: Utils.cloneObject() removed
+ Logging.logSecurityDebug({
+ tenantID: tenantID,
+ action: ServerAction.HTTP_RESPONSE,
+ message: `Axios HTTP Response - ${(executionDurationMillis > 0) ? executionDurationMillis : '?'}ms - ${(sizeOfDataKB > 0) ? sizeOfDataKB : '?'}kB << ${response.config.method.toLocaleUpperCase()}/${response.status} '${response.config.url}'`,
+ module: MODULE_NAME, method: 'interceptor',
+ detailedMessages: {
+ status: response.status,
+ statusText: response.statusText
+ }
+ });
+ }
}
public static logAxiosError(tenantID: string, error: AxiosError): void {

Temp Fix: Add Interceptors for OICP requests