mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-18 01:52:20 +00:00
Update terminal panel
This commit is contained in:
@@ -50,41 +50,6 @@ export function getApiUrl(endpoint: string): string {
|
||||
return `${baseUrl}${normalizedEndpoint}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base URL for WebSocket connections
|
||||
* Automatically handles ws:// vs wss:// based on page protocol (SSL support)
|
||||
*
|
||||
* @param path - WebSocket endpoint path (e.g., '/ws/terminal')
|
||||
* @returns Full WebSocket URL
|
||||
*/
|
||||
export function getWebSocketUrl(path: string): string {
|
||||
if (typeof window === "undefined") {
|
||||
return `ws://localhost:${API_PORT}${path}`
|
||||
}
|
||||
|
||||
const { protocol, hostname, port } = window.location
|
||||
const isStandardPort = port === "" || port === "80" || port === "443"
|
||||
|
||||
// Use wss:// when page is served over https://
|
||||
const wsProtocol = protocol === "https:" ? "wss:" : "ws:"
|
||||
|
||||
// Ensure path starts with /
|
||||
const normalizedPath = path.startsWith("/") ? path : `/${path}`
|
||||
|
||||
let wsUrl: string
|
||||
if (isStandardPort) {
|
||||
// Behind a proxy - WebSocket goes through same host
|
||||
wsUrl = `${wsProtocol}//${hostname}${normalizedPath}`
|
||||
} else {
|
||||
// Direct access - use API port
|
||||
wsUrl = `${wsProtocol}//${hostname}:${API_PORT}${normalizedPath}`
|
||||
}
|
||||
|
||||
console.log(`[v0] getWebSocketUrl: protocol=${protocol}, hostname=${hostname}, port=${port}, isStandardPort=${isStandardPort}, wsUrl=${wsUrl}`)
|
||||
|
||||
return wsUrl
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JWT token from localStorage
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user