Fixes vite dev with arbitrary socketio port

This commit is contained in:
psychedelicious
2022-09-29 09:46:01 +10:00
committed by Lincoln Stein
parent 1a0cf1320b
commit fb6beaa347
5 changed files with 19 additions and 7 deletions

View File

@@ -24,9 +24,20 @@ import * as InvokeAI from '../invokeai';
export const socketioMiddleware = () => {
const { hostname, port } = new URL(window.location.href);
const socketio = io(`http://${hostname}:9090`, {
timeout: 60000,
});
if (import.meta.env.VITE_SOCKETIO_PORT !== undefined) {
console.log(
`Running in Vite dev mode, using socketio port ${
import.meta.env.VITE_SOCKETIO_PORT
}`
);
}
const socketio = io(
`http://${hostname}:${import.meta.env.VITE_SOCKETIO_PORT || port}`,
{
timeout: 60000,
}
);
let areListenersSet = false;
@@ -153,7 +164,6 @@ export const socketioMiddleware = () => {
break;
}
case 'socketio/cancelProcessing': {
emitCancelProcessing();
break;