mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
Support basic auth in opencode sdk
This commit is contained in:
parent
8167e90801
commit
126f2b0600
1 changed files with 13 additions and 0 deletions
|
|
@ -24,6 +24,19 @@ export function createOpencodeClient(config?: Config & { directory?: string }) {
|
|||
}
|
||||
}
|
||||
|
||||
if (config?.baseUrl) {
|
||||
const baseUrl = new URL(config.baseUrl)
|
||||
if (baseUrl.username || baseUrl.password) {
|
||||
config.headers = {
|
||||
...config.headers,
|
||||
Authorization: `Basic ${btoa(`${baseUrl.username}:${baseUrl.password}`)}`,
|
||||
}
|
||||
baseUrl.username = ""
|
||||
baseUrl.password = ""
|
||||
config.baseUrl = baseUrl.toString()
|
||||
}
|
||||
}
|
||||
|
||||
const client = createClient(config)
|
||||
return new OpencodeClient({ client })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue