mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
修复websocket连接域名
This commit is contained in:
parent
efa1fcfbdf
commit
003cdd1e06
|
@ -8,7 +8,7 @@ import fs from 'fs';
|
||||||
import { getPlatform } from '../config/util';
|
import { getPlatform } from '../config/util';
|
||||||
|
|
||||||
export default async ({ server }: { server: Server }) => {
|
export default async ({ server }: { server: Server }) => {
|
||||||
const echo = sockjs.createServer({ prefix: '/ws' });
|
const echo = sockjs.createServer({ prefix: '/api/ws' });
|
||||||
const sockService = Container.get(SockService);
|
const sockService = Container.get(SockService);
|
||||||
|
|
||||||
echo.on('connection', (conn) => {
|
echo.on('connection', (conn) => {
|
||||||
|
|
|
@ -125,13 +125,15 @@ export default function (props: any) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ws.current = new SockJS(
|
ws.current = new SockJS(
|
||||||
`http://127.0.0.1:5600/ws?token=${localStorage.getItem(config.authKey)}`,
|
`${location.origin}/api/ws?token=${localStorage.getItem(config.authKey)}`,
|
||||||
);
|
);
|
||||||
ws.current.onopen = () => {
|
ws.current.onopen = (e) => {
|
||||||
console.log('ws opened');
|
console.log('ws opened', e);
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.current.onclose = () => console.log('ws closed');
|
ws.current.onclose = (e) => {
|
||||||
|
console.log('ws closed', e);
|
||||||
|
};
|
||||||
const wsCurrent = ws.current;
|
const wsCurrent = ws.current;
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user