sdk: throw error if response has text/html content type
parent
ae614d919f
commit
2b4a093da3
|
|
@ -77,6 +77,11 @@ 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("Unexpected content-type: " + contentType)
|
||||
|
||||
return response
|
||||
})
|
||||
return new OpencodeClient({ client })
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue