narinder1231 commited on
Commit
3533a0f
·
1 Parent(s): 130dce0

add token on queryparms instead of onopen event

Browse files
src/hooks/useTextWebhook.ts CHANGED
@@ -18,19 +18,6 @@ const useWebSocket = () => {
18
  setMessages((prevMessages) => [...prevMessages, { text: parsedMessage, sender: "bot" }]);
19
  };
20
 
21
- ws.onopen = () => {
22
- const auth_token = localStorage.getItem("auth_token");
23
- const token = `Bearer ${auth_token}`;
24
- ws.send(
25
- JSON.stringify({
26
- type: "headers",
27
- headers: {
28
- Token: token,
29
- },
30
- })
31
- );
32
- };
33
-
34
  ws.onclose = () => {
35
  wsRef.current = null;
36
  };
 
18
  setMessages((prevMessages) => [...prevMessages, { text: parsedMessage, sender: "bot" }]);
19
  };
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ws.onclose = () => {
22
  wsRef.current = null;
23
  };
src/services/websockets/conversation.ts CHANGED
@@ -3,7 +3,8 @@ import { IConversationWebSocket } from "../../interfaces/conversationWebsocket";
3
  const baseURL = import.meta.env.VITE_WS_URL as string;
4
 
5
  export function conversationWebSocket(data: IConversationWebSocket): WebSocket {
 
6
  return new WebSocket(
7
- `${baseURL}/conversations?conversation_id=${data.conversationId}&modality=${data.modality}`
8
  );
9
  }
 
3
  const baseURL = import.meta.env.VITE_WS_URL as string;
4
 
5
  export function conversationWebSocket(data: IConversationWebSocket): WebSocket {
6
+ const token = localStorage.getItem("auth_token");
7
  return new WebSocket(
8
+ `${baseURL}/conversations?conversation_id=${data.conversationId}&modality=${data.modality}&token=${token}`
9
  );
10
  }