anomalyco / anomalyco/opencode

v2.0.5: opencode serve returns 401 when server auth env vars are unset or empty

Open
#49,452 2 comments 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Sep 17, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

On v2.0.5, opencode serve returns HTTP 401 for a loopback-only server even when both OPENCODE_SERVER_PASSWORD and OPENCODE_SERVER_USERNAME are absent or explicitly empty in a clean HOME/XDG environment. The server logs an auto-generated password. Please clarify whether this is intentional and, if so, how to disable it; otherwise, please treat it as a regression.

Plugins

None.

OpenCode version

v2.0.5 (official opencode upgrade 2.0.5 --method curl).

Steps to reproduce

  1. probe_root=$(mktemp -d); mkdir -p "$probe_root"/{config,data,state,cache,home}
  2. Run: env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOME="$probe_root/home" XDG_CONFIG_HOME="$probe_root/config" XDG_DATA_HOME="$probe_root/data" XDG_STATE_HOME="$probe_root/state" XDG_CACHE_HOME="$probe_root/cache" opencode serve --hostname 127.0.0.1 --port 4097 --print-logs
  3. In another terminal: curl -i http://127.0.0.1:4097/global/health
  4. Stop the server; repeat step 2 with OPENCODE_SERVER_PASSWORD="" OPENCODE_SERVER_USERNAME="" added.

Expected: clarify whether auth should be disabled with variables absent/empty, and provide an opt-out if auth is intentional.

Actual: both variants log an auto-generated password and return 401.

Screenshot and/or share link

None. Do not paste the generated password.

Operating System

Ubuntu 26.04.1 LTS

Terminal

zsh 5.9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.