Fixed a bug in the SocketUtil.js

This commit is contained in:
Mathias Wagner 2023-08-05 22:36:12 +02:00
parent 46bc9ef814
commit 8df6fb93b5
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -1,10 +1,10 @@
import { io } from 'socket.io-client'; import { io } from 'socket.io-client';
const URL = process.env.NODE_ENV === 'production' ? (localStorage.getItem("url") || "https://tools-api.gnmyt.dev/") const getURL = () => process.env.NODE_ENV === 'production' ? (localStorage.getItem("url") || "https://tools-api.gnmyt.dev/")
: "http://localhost:7182/"; : "http://localhost:7182/";
export const createConnection = (type) => { export const createConnection = (type) => {
const socket = io(URL, {autoConnect: false}); const socket = io(getURL(), {autoConnect: false});
socket.on("connect", () => socket.emit("type", type)); socket.on("connect", () => socket.emit("type", type));