23 lines
601 B
JavaScript
23 lines
601 B
JavaScript
import { io } from "socket.io-client";
|
|
|
|
var URL = null
|
|
await fetch("/information.json").then(response => response.json())
|
|
.then(data => {
|
|
if (import.meta.env.DEV) {
|
|
URL = data.backend.development;
|
|
} else {
|
|
URL = data.backend.production;
|
|
}
|
|
}).catch(error => {
|
|
console.error("Erreur lors de la récupération de l'URL du backend :", error);
|
|
});
|
|
|
|
export const socket = io(URL, {
|
|
autoConnect: false,
|
|
reconnectionAttempts: 0,
|
|
auth: {
|
|
token: localStorage.getItem("token") || null,
|
|
sessionId: localStorage.getItem("session") || null
|
|
},
|
|
|
|
}); |