mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-14 16:16:21 +00:00
Update terminal-panel.tsx
This commit is contained in:
@@ -53,14 +53,14 @@ function getWebSocketUrl(): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getApiUrl(): string {
|
function getApiUrl(endpoint?: string): string {
|
||||||
if (typeof window === "undefined") {
|
if (typeof window === "undefined") {
|
||||||
return "http://localhost:8008"
|
return "http://localhost:8008"
|
||||||
}
|
}
|
||||||
|
|
||||||
const { protocol, hostname } = window.location
|
const { protocol, hostname } = window.location
|
||||||
const apiProtocol = protocol === "https:" ? "https:" : "http:"
|
const apiProtocol = protocol === "https:" ? "https:" : "http:"
|
||||||
return `${apiProtocol}//${hostname}:${API_PORT}`
|
return `${apiProtocol}//${hostname}:${API_PORT}${endpoint || ""}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const proxmoxCommands = [
|
const proxmoxCommands = [
|
||||||
@@ -225,7 +225,8 @@ export const TerminalPanel: React.FC<TerminalPanelProps> = ({ websocketUrl, onCl
|
|||||||
try {
|
try {
|
||||||
setIsSearching(true)
|
setIsSearching(true)
|
||||||
|
|
||||||
const apiUrl = getApiUrl()
|
const searchEndpoint = `/api/terminal/search-command?q=${encodeURIComponent(query)}`
|
||||||
|
const apiUrl = getApiUrl(searchEndpoint)
|
||||||
const token = typeof window !== "undefined" ? localStorage.getItem("proxmenux-auth-token") : null
|
const token = typeof window !== "undefined" ? localStorage.getItem("proxmenux-auth-token") : null
|
||||||
|
|
||||||
const headers: Record<string, string> = {
|
const headers: Record<string, string> = {
|
||||||
@@ -236,7 +237,7 @@ export const TerminalPanel: React.FC<TerminalPanelProps> = ({ websocketUrl, onCl
|
|||||||
headers["Authorization"] = `Bearer ${token}`
|
headers["Authorization"] = `Bearer ${token}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(`${apiUrl}/api/terminal/search-command?q=${encodeURIComponent(query)}`, {
|
const response = await fetch(apiUrl, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers,
|
headers,
|
||||||
signal: AbortSignal.timeout(10000),
|
signal: AbortSignal.timeout(10000),
|
||||||
|
|||||||
Reference in New Issue
Block a user