Skip to content

Commit 792c4fb

Browse files
feature: this commit introduces axios clients
1 parent 50ef9b2 commit 792c4fb

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

UIs/Landing/lib/axios.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import LocalStorage from "@/constants/localstorage-constants";
2+
import axios from "axios";
3+
4+
export const httpClient = axios.create({
5+
baseURL: process.env.NEXT_PUBLIC_API_URL,
6+
headers: {
7+
"Content-Type": "application/json"
8+
}
9+
});
10+
11+
export const federationClient = axios.create({
12+
baseURL: process.env.NEXT_PUBLIC_FEDERATION_API_URL,
13+
headers: {
14+
"Content-Type": "application/json",
15+
"Realm": process.env.NEXT_PUBLIC_REALM
16+
}
17+
});
18+
19+
20+
httpClient.interceptors.request.use((configuration) => {
21+
const token = typeof window !== "undefined"
22+
? localStorage.getItem(LocalStorage.AccessToken)
23+
: null;
24+
25+
if (token) {
26+
configuration.headers.Authorization = `Bearer ${token}`;
27+
}
28+
29+
return configuration;
30+
});

0 commit comments

Comments
 (0)