Version 1.0.0 - Initialisation du depot
This commit is contained in:
22
src/socket.js
Normal file
22
src/socket.js
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
},
|
||||
});
|
Reference in New Issue
Block a user