Spaces:
Runtime error
Runtime error
Update frontend/src/App.tsx
Browse files- frontend/src/App.tsx +16 -15
frontend/src/App.tsx
CHANGED
@@ -10,21 +10,22 @@ const userEnv = {};
|
|
10 |
const apiClient = new ChainlitAPI(CHAINLIT_SERVER);
|
11 |
|
12 |
function App() {
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
28 |
|
29 |
|
30 |
return (
|
|
|
10 |
const apiClient = new ChainlitAPI(CHAINLIT_SERVER);
|
11 |
|
12 |
function App() {
|
13 |
+
const { connect } = useChatSession();
|
14 |
+
const session = useRecoilValue(sessionState);
|
15 |
+
|
16 |
+
useEffect(() => {
|
17 |
+
if (session?.socket.connected) {
|
18 |
+
return
|
19 |
+
}
|
20 |
+
fetch(apiClient
|
21 |
+
.buildEndpoint("/custom-auth")).then((res) => {
|
22 |
+
return res.json();
|
23 |
+
}
|
24 |
+
).then((data) => {
|
25 |
+
connect({ client: apiClient, userEnv, accessToken: `Bearer: ${data.token}` });
|
26 |
+
}
|
27 |
+
)
|
28 |
+
}, []);
|
29 |
|
30 |
|
31 |
return (
|