We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 50ef9b2 commit 792c4fbCopy full SHA for 792c4fb
1 file changed
UIs/Landing/lib/axios.ts
@@ -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
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