Skip to content

Commit 29dee14

Browse files
committed
added session instead of token
1 parent 3448ebc commit 29dee14

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"echarts-for-react": "^3.0.2",
2828
"framer-motion": "^9.0.2",
2929
"html-react-parser": "^3.0.16",
30+
"js-cookie": "^3.0.5",
3031
"minimist": "^1.2.8",
3132
"query-string": "^8.1.0",
3233
"react": "^18.2.0",

ui/src/utils/Api.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import axios from "axios";
2+
// eslint-disable-next-line import/no-extraneous-dependencies
3+
import Cookies from "js-cookie";
24
import { TAxiosWrapper } from "../types";
35

4-
const TOKEN = "clerk-db-jwt";
6+
const TOKEN = "__session";
57
const PATH_PREFIX = "/api/v1/";
68
const Instance = axios.create({
79
baseURL: import.meta.env.VITE_BASE_URL
@@ -10,6 +12,10 @@ const Instance = axios.create({
1012
timeout: 8000,
1113
});
1214

15+
const getToken = () => {
16+
return Cookies.get(TOKEN);
17+
};
18+
1319
export default function ApiCall<T>({
1420
path,
1521
method,
@@ -31,7 +37,7 @@ export default function ApiCall<T>({
3137
},
3238
],
3339
headers: {
34-
Authorization: `Bearer ${token}`,
40+
Authorization: `Bearer ${getToken() || token}`,
3541
},
3642
});
3743
}

0 commit comments

Comments
 (0)