Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

chore: interceptor is updated

Palash gupta039201acaee0
diff --git a/frontend/src/AppRoutes/utils.ts b/frontend/src/AppRoutes/utils.ts
index 222f4c02de..5f3405ceea 100644
--- a/frontend/src/AppRoutes/utils.ts
+++ b/frontend/src/AppRoutes/utils.ts
@@ -40,7 +40,7 @@ const afterLogin = async (
}),
]);
- if (getUserResponse.statusCode === 200) {
+ if (getUserResponse.statusCode === 200 && getUserResponse.payload) {
store.dispatch<AppActions>({
type: LOGGED_IN,
payload: {
diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts
index c2fbe4b810..82f4bdc010 100644
--- a/frontend/src/api/index.ts
+++ b/frontend/src/api/index.ts
@@ -35,7 +35,6 @@ const interceptorRejected = async (
try {
if (axios.isAxiosError(value) && value.response) {
const { response } = value;
- console.log(response);
// reject the refresh token error
if (response.status === 401 && response.config.url !== '/login') {
const response = await loginApi({
@@ -43,32 +42,37 @@ const interceptorRejected = async (
});
if (response.statusCode === 200) {
- await afterLogin(
+ const user = await afterLogin(
response.payload.userId,
response.payload.accessJwt,
response.payload.refreshJwt,
);
- const reResponse = await axios(
- `${value.config.baseURL}${value.config.url?.substring(1)}`,
- {
- method: value.config.method,
- headers: {
- ...value.config.headers,
- Authorization: `Bearer ${response.payload.accessJwt}`,
+ if (user) {
+ const reResponse = await axios(
+ `${value.config.baseURL}${value.config.url?.substring(1)}`,
+ {
+ method: value.config.method,
+ headers: {
+ ...value.config.headers,
+ Authorization: `Bearer ${response.payload.accessJwt}`,
+ },
+ data: {
+ ...JSON.parse(value.config.data || '{}'),
+ },
},
- data: {
- ...JSON.parse(value.config.data || '{}'),
- },
- },
- );
+ );
+
+ if (reResponse.status === 200) {
+ return await Promise.resolve(reResponse);
+ }
+ Logout();
- if (reResponse.status === 200) {
- return await Promise.resolve(reResponse);
+ return await Promise.reject(reResponse);
}
Logout();
- return await Promise.reject(reResponse);
+ return await Promise.reject(value);
}
Logout();
}
@@ -80,7 +84,7 @@ const interceptorRejected = async (
}
return await Promise.reject(value);
} catch (error) {
- return Promise.reject(value);
+ return await Promise.reject(error);
}
};
diff --git a/frontend/src/api/user/getUser.ts b/frontend/src/api/user/getUser.ts
index 8046e85de2..6bedb78d2e 100644
--- a/frontend/src/api/user/getUser.ts
+++ b/frontend/src/api/user/getUser.ts
@@ -17,7 +17,7 @@ const getUser = async (
return {
statusCode: 200,
error: null,
- message: response.data.status,
+ message: 'Success',
payload: response.data,
};
} catch (error) {