mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-04 23:40:48 +00:00
sdk: throw error if response has text/html content type (#21289)
This commit is contained in:
parent
ae17b416b8
commit
26d35583c5
1 changed files with 8 additions and 2 deletions
|
|
@ -77,6 +77,12 @@ export function createOpencodeClient(config?: Config & { directory?: string; exp
|
|||
workspace: config?.experimental_workspaceID,
|
||||
}),
|
||||
)
|
||||
const result = new OpencodeClient({ client })
|
||||
return result
|
||||
client.interceptors.response.use((response) => {
|
||||
const contentType = response.headers.get("content-type")
|
||||
if (contentType === "text/html")
|
||||
throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)")
|
||||
|
||||
return response
|
||||
})
|
||||
return new OpencodeClient({ client })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue