mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Fix Basic Auth handling in v2 client and CLI status command
This commit is contained in:
1 parent
e14f4c5fa6
commit
2b7c3f7991
2 files changed
+24
-2
No files matched your search
@@ -31,7 +31,18 @@ export async function run(argv: StatusArgs): Promise<void> {
|
||||
|
||||
async function tryFetchSessionOutput(serverUrl: string, sessionId: string, directory: string) {
|
||||
try {
|
||||
const client = createOpencodeClient({ baseUrl: serverUrl, directory })
|
||||
const url = new URL(serverUrl)
|
||||
const password = url.password || process.env['OPENCODE_SERVER_PASSWORD']
|
||||
const cleanUrl = new URL(url.toString())
|
||||
cleanUrl.username = ''
|
||||
cleanUrl.password = ''
|
||||
const clientConfig: Parameters<typeof createOpencodeClient>[0] = { baseUrl: cleanUrl.toString(), directory }
|
||||
if (password) {
|
||||
clientConfig.headers = {
|
||||
Authorization: `Basic ${Buffer.from(`opencode:${password}`).toString('base64')}`,
|
||||
}
|
||||
}
|
||||
const client = createOpencodeClient(clientConfig)
|
||||
return await fetchSessionOutput(client, sessionId, directory)
|
||||
} catch {
|
||||
return null
|
||||
|
||||
@@ -264,7 +264,18 @@ export function createMemoryPlugin(config: PluginConfig): Plugin {
|
||||
const { directory, project, client } = input
|
||||
const projectId = project.id
|
||||
|
||||
const v2 = createV2Client({ baseUrl: input.serverUrl.toString(), directory })
|
||||
const serverUrl = input.serverUrl
|
||||
const serverPassword = serverUrl.password || process.env['OPENCODE_SERVER_PASSWORD']
|
||||
const cleanUrl = new URL(serverUrl.toString())
|
||||
cleanUrl.username = ''
|
||||
cleanUrl.password = ''
|
||||
const v2ClientConfig: Parameters<typeof createV2Client>[0] = { baseUrl: cleanUrl.toString(), directory }
|
||||
if (serverPassword) {
|
||||
v2ClientConfig.headers = {
|
||||
Authorization: `Basic ${Buffer.from(`opencode:${serverPassword}`).toString('base64')}`,
|
||||
}
|
||||
}
|
||||
const v2 = createV2Client(v2ClientConfig)
|
||||
|
||||
const loggingConfig = config.logging
|
||||
const logger = createLogger({
|
||||
|
||||
Reference in new issue
Block a user