Skip to content

Commit 5bb80eb

Browse files
committed
fix
1 parent 8799c0f commit 5bb80eb

3 files changed

Lines changed: 38 additions & 5 deletions

File tree

backend/core/settings.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,33 @@ def get_cors_origins(self) -> List[str]:
327327
if self.vercel_url:
328328
origins.append(f"https://{self.vercel_url}")
329329

330-
# Add local network IPs for development
330+
# Add local network IPs for development (including WSL2)
331331
import socket
332332

333333
try:
334+
# Get all IPs from all network interfaces
335+
local_ips = set()
334336
hostname = socket.gethostname()
335-
local_ip = socket.gethostbyname(hostname)
336-
origins.extend([f"http://{local_ip}:5173", f"http://{local_ip}:5174"])
337+
# Try hostname-based lookup
338+
try:
339+
local_ips.add(socket.gethostbyname(hostname))
340+
except Exception:
341+
pass
342+
# Try getting all addresses for the hostname
343+
try:
344+
for info in socket.getaddrinfo(hostname, None, socket.AF_INET):
345+
local_ips.add(info[4][0])
346+
except Exception:
347+
pass
348+
# Try connecting to external to find default route IP (works in WSL2)
349+
try:
350+
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
351+
s.connect(("8.8.8.8", 80))
352+
local_ips.add(s.getsockname()[0])
353+
except Exception:
354+
pass
355+
for local_ip in local_ips:
356+
origins.extend([f"http://{local_ip}:5173", f"http://{local_ip}:5174"])
337357
except Exception:
338358
pass
339359

frontend/src/components/chat-room/message-list/MessageList.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,20 @@ export const MessageList = memo(({ messages, roomId }: MessageListProps) => {
8484

8585
const copyToClipboard = useCallback(async (messageId: number | string, content: string) => {
8686
try {
87-
await navigator.clipboard.writeText(content);
87+
// Use modern clipboard API if available
88+
if (navigator.clipboard?.writeText) {
89+
await navigator.clipboard.writeText(content);
90+
} else {
91+
// Fallback for non-secure contexts or older browsers
92+
const textArea = document.createElement('textarea');
93+
textArea.value = content;
94+
textArea.style.position = 'fixed';
95+
textArea.style.left = '-9999px';
96+
document.body.appendChild(textArea);
97+
textArea.select();
98+
document.execCommand('copy');
99+
document.body.removeChild(textArea);
100+
}
88101
setCopiedMessageId(messageId);
89102
setTimeout(() => setCopiedMessageId(null), 2000);
90103
} catch (err) {

frontend/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default defineConfig({
1111
},
1212
},
1313
server: {
14-
host: '127.0.0.1', // Localhost only - not exposed to network
14+
host: '0.0.0.0', // Exposed to network (needed for WSL2 -> Windows access)
1515
port: 5173,
1616
strictPort: true, // Fail if port is in use (needed for Tauri)
1717
},

0 commit comments

Comments
 (0)