diff --git a/.gitignore b/.gitignore index 02c17fd..7efc8a8 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,9 @@ src-tauri/target/ .env.local .env.*.local +# Config +config.json + # OS .DS_Store Thumbs.db diff --git a/server/index.js b/server/index.js index 3ce16d3..b22668a 100644 --- a/server/index.js +++ b/server/index.js @@ -107,12 +107,10 @@ io.on('connection', (socket) => { }); const PORT = process.env.PORT || 3000; -const HOST = process.env.HOST || '0.0.0.0'; +const HOST = process.env.HOST || '127.0.0.1'; httpServer.listen(PORT, HOST, () => { console.log(`P2P Transfer Server running on http://${HOST}:${PORT}`); - console.log(`Local access: http://localhost:${PORT}`); - console.log(`LAN access: http://${getLocalIP()}:${PORT}`); }); function getLocalIP() { diff --git a/src/composables/useSocket.js b/src/composables/useSocket.js index c3d625a..d1b0388 100644 --- a/src/composables/useSocket.js +++ b/src/composables/useSocket.js @@ -1,11 +1,16 @@ import { ref, onMounted, onUnmounted } from 'vue'; import { io } from 'socket.io-client'; import { generateUserId } from '../utils'; +import config from '../../config.json'; function isTauri() { return window.__TAURI__ !== undefined; } +function getDefaultServerUrl() { + return config.defaultServerUrl || 'http://localhost:3000'; +} + export function useSocket() { const socket = ref(null); const userId = ref(''); @@ -13,7 +18,7 @@ export function useSocket() { const connected = ref(false); const roomUsers = ref([]); const roomId = ref(''); - const serverUrl = ref(localStorage.getItem('p2p-server-url') || 'http://localhost:3000'); + const serverUrl = ref(localStorage.getItem('p2p-server-url') || getDefaultServerUrl()); onMounted(() => { userId.value = generateUserId();