Merge 728919f7bf
into 7ec201d011
This commit is contained in:
commit
11d539c805
1 changed files with 10 additions and 5 deletions
|
@ -393,11 +393,16 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
||||||
const [isReady, setIsReady] = useState(false);
|
const [isReady, setIsReady] = useState(false);
|
||||||
|
|
||||||
const [isWSReady, setIsWSReady] = useState(false);
|
const [isWSReady, setIsWSReady] = useState(false);
|
||||||
const ws = useSocket(
|
|
||||||
process.env.NEXT_PUBLIC_WS_URL!,
|
let websocketUrl = process.env.NEXT_PUBLIC_WS_URL!;
|
||||||
setIsWSReady,
|
if (websocketUrl.startsWith('/')) {
|
||||||
setHasError,
|
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 [loading, setLoading] = useState(false);
|
||||||
const [messageAppeared, setMessageAppeared] = useState(false);
|
const [messageAppeared, setMessageAppeared] = useState(false);
|
||||||
|
|
Loading…
Add table
Reference in a new issue