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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat: refresh token is fixed (#1049)
palash-signoz5f529e1c10ce
diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.tsindex d7e04ddbbc..b9396a5013 100644--- a/frontend/src/api/index.ts+++ b/frontend/src/api/index.ts@@ -1,3 +1,4 @@+/* eslint-disable sonarjs/cognitive-complexity *//* eslint-disable no-param-reassign *//* eslint-disable @typescript-eslint/no-explicit-any */import getLocalStorageApi from 'api/browser/localstorage/get';@@ -31,32 +32,54 @@ const interceptorsRequestResponse = (const interceptorRejected = async (value: AxiosResponse<any>,): Promise<AxiosResponse<any>> => {- 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({- refreshToken: store.getState().app.user?.accessJwt,- });-- if (response.statusCode === 200) {- await afterLogin(- response.payload.userId,- response.payload.accessJwt,- response.payload.refreshJwt,- );- } else {+ 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({+ refreshToken: store.getState().app.user?.refreshJwt,+ });++ if (response.statusCode === 200) {+ 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}`,+ },+ data: {+ ...JSON.parse(value.config.data || '{}'),+ },+ },+ );++ if (reResponse.status === 200) {+ return await Promise.resolve(reResponse);+ }+ return await Promise.reject(reResponse);+ }Logout();}- }- // when refresh token is expired- if (response.status === 401 && response.config.url === '/login') {- Logout();+ // when refresh token is expired+ if (response.status === 401 && response.config.url === '/login') {+ Logout();+ }}+ return await Promise.reject(value);+ } catch (error) {+ return Promise.reject(value);}- return Promise.reject(value);};const instance = axios.create({diff --git a/frontend/src/pages/SignUp/index.tsx b/frontend/src/pages/SignUp/index.tsxindex beb57ad08c..2a073a756a 100644--- a/frontend/src/pages/SignUp/index.tsx+++ b/frontend/src/pages/SignUp/index.tsx@@ -1,7 +1,6 @@import { Typography } from 'antd';import getUserVersion from 'api/user/getVersion';import Spinner from 'components/Spinner';-import ROUTES from 'constants/routes';import React from 'react';import { useTranslation } from 'react-i18next';import { useQueries } from 'react-query';@@ -15,8 +14,6 @@ function SignUp(): JSX.Element {const { t } = useTranslation('common');const { isLoggedIn } = useSelector<AppState, AppReducer>((state) => state.app);- useLoggedInNavigate(ROUTES.APPLICATION);-const [versionResponse] = useQueries([{queryFn: getUserVersion,