diff --git a/src/services/chatApi.ts b/src/services/chatApi.ts index 1661e66..a98e000 100644 --- a/src/services/chatApi.ts +++ b/src/services/chatApi.ts @@ -3,18 +3,16 @@ import { ChatMessage } from '../types/Types'; import io from 'socket.io-client'; const token = localStorage.getItem('token'); + export const chatApi = mavericksApi.injectEndpoints({ endpoints: builder => ({ getMessages: builder.query<{ chat: ChatMessage[] }, string>({ - query: token => ({ + query: () => ({ url: 'chats', - headers: { - Authorization: token, - }, }), async onCacheEntryAdded(arg, { updateCachedData, cacheDataLoaded, cacheEntryRemoved }) { if (typeof arg !== 'undefined') { - const socket = io('https://e-commerce-mavericcks-bn-staging-istf.onrender.com', { auth: { token } }); + const socket = io('https://mavericks.nijohn.dev', { auth: { token } }); try { await cacheDataLoaded; socket.on('returnMessage', newMessage => { @@ -32,7 +30,7 @@ export const chatApi = mavericksApi.injectEndpoints({ }), sendMessage: builder.mutation({ queryFn: body => { - const socket = io('https://e-commerce-mavericcks-bn-staging-istf.onrender.com/', { + const socket = io('https://mavericks.nijohn.dev', { auth: { token }, }); socket.emit('sentMessage', body); diff --git a/src/services/index.ts b/src/services/index.ts index 0fe7e56..66f2c33 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -4,7 +4,7 @@ import { RootState } from '../redux/store'; export const mavericksApi = createApi({ reducerPath: 'mavericksApi', baseQuery: fetchBaseQuery({ - baseUrl: 'https://e-commerce-mavericcks-bn-staging-istf.onrender.com/api/', + baseUrl: 'https://mavericks.nijohn.dev/api/', prepareHeaders: (headers, { getState }) => { const token = (getState() as RootState).user.token; if (token) { diff --git a/src/utils/handleGoogleAuthentication.ts b/src/utils/handleGoogleAuthentication.ts index a33cf1b..3d38d0a 100644 --- a/src/utils/handleGoogleAuthentication.ts +++ b/src/utils/handleGoogleAuthentication.ts @@ -1,6 +1,6 @@ const handleGoogleAuthentication = (e: any) => { e.preventDefault(); - window.location.assign('https://e-commerce-mavericcks-bn-staging-istf.onrender.com/api/auth/google'); + window.location.assign('https://mavericks.nijohn.dev/api/auth/google'); }; export default handleGoogleAuthentication;