fix(auth): honor OPENCODE_SERVER_USERNAME env var for basic auth (#1705)

Fix #1685: the Basic auth header for the OpenCode server was hardcoded
to use the username 'opencode', ignoring OPENCODE_SERVER_USERNAME. Users
who set a custom username got 401 errors because the server expected a
different credential.

Both call sites (web server auth-state-runtime.js and VS Code
extension opencode.ts) now read process.env.OPENCODE_SERVER_USERNAME
with a fallback to 'opencode' to preserve prior behavior.

Co-authored-by: Leonid Skorobogatyy <bash@opencode.itc.local>
This commit is contained in:
bashrusakh
2026-06-23 21:50:14 +03:00
committed by GitHub
co-authored by Leonid Skorobogatyy
parent eae09d4576
commit 4feddfa810
2 changed files with 4 additions and 2 deletions
@@ -51,7 +51,8 @@ export const createOpenCodeAuthStateRuntime = (dependencies) => {
return {};
}
const credentials = Buffer.from(`opencode:${password}`).toString('base64');
const username = process.env.OPENCODE_SERVER_USERNAME || 'opencode';
const credentials = Buffer.from(`${username}:${password}`).toString('base64');
return { Authorization: `Basic ${credentials}` };
};