fix: Prevent Authorization header on external URLs (#9061)
🐛 (api.tsx): fix issue where Authorization header was not being set correctly for internal requests 💡 (api.tsx): improve logic to set Authorization header only for internal requests and add custom headers for all requests
This commit is contained in:
parent
0f89e39da1
commit
9b3356e1c7
1 changed files with 4 additions and 4 deletions
|
|
@ -49,11 +49,11 @@ function ApiInterceptor() {
|
||||||
request: (url, config) => {
|
request: (url, config) => {
|
||||||
const accessToken = customGetAccessToken();
|
const accessToken = customGetAccessToken();
|
||||||
|
|
||||||
if (accessToken && !isAuthorizedURL(config?.url)) {
|
|
||||||
config.headers["Authorization"] = `Bearer ${accessToken}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isExternalURL(url)) {
|
if (!isExternalURL(url)) {
|
||||||
|
if (accessToken && !isAuthorizedURL(config?.url)) {
|
||||||
|
config.headers["Authorization"] = `Bearer ${accessToken}`;
|
||||||
|
}
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(customHeaders)) {
|
for (const [key, value] of Object.entries(customHeaders)) {
|
||||||
config.headers[key] = value;
|
config.headers[key] = value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue