add websocket subpath support
This commit is contained in:
parent
f37686189e
commit
68048dfd56
1 changed files with 10 additions and 1 deletions
|
@ -393,8 +393,17 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
|||
const [isReady, setIsReady] = useState(false);
|
||||
|
||||
const [isWSReady, setIsWSReady] = useState(false);
|
||||
|
||||
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(
|
||||
process.env.NEXT_PUBLIC_WS_URL!,
|
||||
websocketUrl,
|
||||
setIsWSReady,
|
||||
setHasError,
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue