fix: 채팅 url 업데이트
This commit is contained in:
parent
4e7c427fa3
commit
b51a604697
@ -20,7 +20,7 @@ export default function useChatRoom(roomId) {
|
||||
}
|
||||
|
||||
chatClient.publish({
|
||||
destination: `/pub/message/${roomId}`,
|
||||
destination: `/pub/chat.message.${roomId}`,
|
||||
body: JSON.stringify({
|
||||
userId: USER_ID,
|
||||
name: userName,
|
||||
@ -32,7 +32,7 @@ export default function useChatRoom(roomId) {
|
||||
|
||||
useEffect(() => {
|
||||
client.onConnect = () => {
|
||||
client.subscribe(`/sub/channel/${roomId}`, (response) => {
|
||||
client.subscribe(`/exchange/chat.exchange/*.room.${roomId}`, (response) => {
|
||||
const data = JSON.parse(response.body);
|
||||
const { content: message, name } = data;
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { RouterProvider } from 'react-router-dom';
|
||||
@ -10,9 +9,7 @@ const queryClient = new QueryClient({
|
||||
});
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')).render(
|
||||
<React.StrictMode>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<RouterProvider router={router} />
|
||||
</QueryClientProvider>
|
||||
</React.StrictMode>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<RouterProvider router={router} />
|
||||
</QueryClientProvider>
|
||||
);
|
||||
|
@ -6,7 +6,6 @@ const instance = axios.create({
|
||||
timeout: 1000,
|
||||
headers: {
|
||||
'Content-type': 'application/json;charset=utf-8',
|
||||
'Access-Control-Allow-Origin': import.meta.env.VITE_ORIGIN,
|
||||
},
|
||||
withCredentials: true,
|
||||
});
|
||||
@ -28,16 +27,25 @@ instance.interceptors.response.use(
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
// TODO: api url update
|
||||
const REFRESH_API_URL = '/refresh-token';
|
||||
const REFRESH_API_URL = '/user/refresh';
|
||||
|
||||
return instance.post(REFRESH_API_URL).then((response) => {
|
||||
const { accessToken } = response.data;
|
||||
return instance
|
||||
.post(REFRESH_API_URL)
|
||||
.then((response) => {
|
||||
const { accessToken } = response.data;
|
||||
|
||||
useBoundStore.setState({ token: accessToken });
|
||||
error.config.headers.Authorization = `${accessToken}`;
|
||||
return instance(error.config);
|
||||
});
|
||||
console.log(accessToken);
|
||||
useBoundStore.setState({ token: accessToken });
|
||||
error.config.headers.Authorization = `${accessToken}`;
|
||||
return instance(error.config);
|
||||
})
|
||||
.catch((error) => {
|
||||
useBoundStore.setState({ token: null });
|
||||
console.log(error);
|
||||
console.log('---로그아웃----');
|
||||
// TODO: redirect to home
|
||||
return Promise.reject(error);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
import { Client } from '@stomp/stompjs';
|
||||
import useBoundStore from '../../store';
|
||||
|
||||
export const chatClient = new Client({
|
||||
brokerURL: import.meta.env.VITE_CHAT_URL,
|
||||
// TODO: debug 제거
|
||||
debug: (str) => console.log(str),
|
||||
reconnectDelay: 5000,
|
||||
debug: import.meta.env.DEV ? (str) => console.log(str) : () => {},
|
||||
reconnectDelay: 3000,
|
||||
connectHeaders: {
|
||||
Authorization: useBoundStore.getState().token,
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user