mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-07 06:52:28 +00:00
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:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user