fix: use baseUrl for Socket.IO connection to support separate frontend hosting

Previously, useTerminalSocket used a relative path `/terminal` for Socket.IO,
which would connect to the frontend host instead of the actual HAPI server.
Now it uses the baseUrl from context to connect to the correct server, enabling
scenarios like hosting the frontend on GitHub Pages while the server runs elsewhere.
This commit is contained in:
weishu
2026-01-14 11:27:35 +08:00
parent 584a912311
commit 7003bda706
4 changed files with 10 additions and 5 deletions
+3 -2
View File
@@ -51,7 +51,7 @@ const QUICK_INPUTS = [
export default function TerminalPage() {
const { sessionId } = useParams({ from: '/sessions/$sessionId/terminal' })
const { api, token } = useAppContext()
const { api, token, baseUrl } = useAppContext()
const goBack = useAppGoBack()
const { session } = useSession(api, sessionId)
const terminalId = useMemo(() => {
@@ -77,7 +77,8 @@ export default function TerminalPage() {
} = useTerminalSocket({
token,
sessionId,
terminalId
terminalId,
baseUrl
})
useEffect(() => {