fix: Handle duplicate requests in ApiInterceptor
This commit is contained in:
parent
4358ff5255
commit
b9e1a3c0c5
1 changed files with 6 additions and 5 deletions
|
|
@ -48,7 +48,7 @@ function ApiInterceptor() {
|
||||||
}
|
}
|
||||||
await clearBuildVerticesState(error);
|
await clearBuildVerticesState(error);
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const isAuthorizedURL = (url) => {
|
const isAuthorizedURL = (url) => {
|
||||||
|
|
@ -65,10 +65,10 @@ function ApiInterceptor() {
|
||||||
const parsedURL = new URL(url);
|
const parsedURL = new URL(url);
|
||||||
|
|
||||||
const isDomainAllowed = authorizedDomains.some(
|
const isDomainAllowed = authorizedDomains.some(
|
||||||
(domain) => parsedURL.origin === new URL(domain).origin
|
(domain) => parsedURL.origin === new URL(domain).origin,
|
||||||
);
|
);
|
||||||
const isEndpointAllowed = authorizedEndpoints.some((endpoint) =>
|
const isEndpointAllowed = authorizedEndpoints.some((endpoint) =>
|
||||||
parsedURL.pathname.includes(endpoint)
|
parsedURL.pathname.includes(endpoint),
|
||||||
);
|
);
|
||||||
|
|
||||||
return isDomainAllowed || isEndpointAllowed;
|
return isDomainAllowed || isEndpointAllowed;
|
||||||
|
|
@ -87,6 +87,7 @@ function ApiInterceptor() {
|
||||||
|
|
||||||
if (!checkRequest) {
|
if (!checkRequest) {
|
||||||
controller.abort("Duplicate Request");
|
controller.abort("Duplicate Request");
|
||||||
|
console.error("Duplicate Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
const accessToken = cookies.get("access_token_lf");
|
const accessToken = cookies.get("access_token_lf");
|
||||||
|
|
@ -101,7 +102,7 @@ function ApiInterceptor() {
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|
@ -133,7 +134,7 @@ function ApiInterceptor() {
|
||||||
if (error?.config?.headers) {
|
if (error?.config?.headers) {
|
||||||
delete error.config.headers["Authorization"];
|
delete error.config.headers["Authorization"];
|
||||||
error.config.headers["Authorization"] = `Bearer ${cookies.get(
|
error.config.headers["Authorization"] = `Bearer ${cookies.get(
|
||||||
"access_token_lf"
|
"access_token_lf",
|
||||||
)}`;
|
)}`;
|
||||||
const response = await axios.request(error.config);
|
const response = await axios.request(error.config);
|
||||||
return response;
|
return response;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue