Compare commits

...

3 Commits

Author SHA1 Message Date
07c50a02c5 Merge 728919f7bf into 115e6b2a71 2025-02-15 21:40:19 +01:00
nix
728919f7bf formating 2025-01-31 20:09:58 +01:00
nix
68048dfd56 add websocket subpath support 2025-01-31 20:01:26 +01:00

View File

@ -377,11 +377,16 @@ const ChatWindow = ({ id }: { id?: string }) => {
const [isReady, setIsReady] = useState(false);
const [isWSReady, setIsWSReady] = useState(false);
const ws = useSocket(
process.env.NEXT_PUBLIC_WS_URL!,
setIsWSReady,
setHasError,
);
let websocketUrl = process.env.NEXT_PUBLIC_WS_URL!;
if (websocketUrl.startsWith('/')) {
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
const host = window.location.host;
const path = websocketUrl;
websocketUrl = `${protocol}${host}${path}`;
}
const ws = useSocket(websocketUrl, setIsWSReady, setHasError);
const [loading, setLoading] = useState(false);
const [messageAppeared, setMessageAppeared] = useState(false);