route lms admin socket through lms api path

This commit is contained in:
2026-07-08 09:42:59 +09:00
parent b581ee59d3
commit 6d64337467
3 changed files with 11 additions and 4 deletions
+4 -2
View File
@@ -3,7 +3,8 @@ import { ArrowLeft, ChevronRight, Loader2, MessageCircle, Send, UserRound, X } f
import { io } from 'socket.io-client';
import type { Socket } from 'socket.io-client';
import {
CHAT_SOCKET_BASE_URL,
CHAT_SOCKET_ORIGIN,
CHAT_SOCKET_PATH,
createInstructorChatMessage,
getInstructorChatThread,
listInstructorChatThreads,
@@ -100,8 +101,9 @@ export function InstructorChatPanel({ session, open, initialThreadId = null, ini
useEffect(() => {
if (!open) return;
const socket: Socket = io(CHAT_SOCKET_BASE_URL, {
const socket: Socket = io(CHAT_SOCKET_ORIGIN, {
auth: { token: session.accessToken },
path: CHAT_SOCKET_PATH,
transports: ['websocket', 'polling'],
});
+3 -2
View File
@@ -26,7 +26,7 @@ import { InstructorChatPanel } from '../components/InstructorChatPanel';
import { useToast } from '../components/ToastProvider';
import autonomyLogo from '../assets/icon.png';
import { useProfileAvatar } from '../hooks/useProfileAvatar';
import { CHAT_SOCKET_BASE_URL } from '../lib/chat';
import { CHAT_SOCKET_ORIGIN, CHAT_SOCKET_PATH } from '../lib/chat';
import type { InstructorCourse } from '../lib/courses';
import { deleteProfileAvatar, notifyProfileAvatarDeleted, notifyProfileAvatarUpdated, resizeImageToWebp, uploadProfileAvatar } from '../lib/profileAvatar';
import { navItems, type AppRoute } from '../routes';
@@ -157,8 +157,9 @@ export function InstructorLayout({ session, route, onNavigate, onLogout, courses
}, [notificationPage, notificationTotalPages]);
useEffect(() => {
const socket: Socket = io(CHAT_SOCKET_BASE_URL, {
const socket: Socket = io(CHAT_SOCKET_ORIGIN, {
auth: { token: session.accessToken },
path: CHAT_SOCKET_PATH,
transports: ['websocket', 'polling'],
});
+4
View File
@@ -24,6 +24,10 @@ export type InstructorChatThread = {
const CHAT_API_BASE_URL = (import.meta.env.VITE_API_BASE_URL ?? 'https://workspace.autonomystudio.net/lms-api/api').replace(/\/+$/, '');
export const CHAT_SOCKET_BASE_URL = CHAT_API_BASE_URL.replace(/\/api$/, '');
const CHAT_SOCKET_URL = new URL(CHAT_SOCKET_BASE_URL || '/', window.location.origin);
const CHAT_SOCKET_PREFIX = CHAT_SOCKET_URL.pathname.replace(/\/+$/, '');
export const CHAT_SOCKET_ORIGIN = CHAT_SOCKET_URL.origin;
export const CHAT_SOCKET_PATH = `${CHAT_SOCKET_PREFIX}/socket.io`;
type ChatThreadsPayload = {
threads?: unknown[];