Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

cli: pair QR code encodes localhost link when server listens on 0.0.0.0

Đang mở Phù hợp với người mới
#54,871 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
cli, networking

Hướng nghiên cứu

Bắt đầu từ lệnh opencode pair và theo dõi cách lệnh chọn URL cho mã QR khi in cả liên kết loopback lẫn LAN. Issue cung cấp một cấu hình có thể tái hiện và cách khắc phục bằng --url; hãy so sánh các đầu ra đó để tìm điểm chọn URL. Hoàn tất khi mã QR mặc định mã hóa một liên kết có thể truy cập từ thiết bị khác trong LAN.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

reproduced

Summary

When the background service listens on all interfaces (hostname 0.0.0.0), opencode pair prints two one-time links (loopback and LAN IP) but the QR code encodes the 127.0.0.1 link, which can never be reached from another device — so scanning it with a phone on the same network always fails.

Environment

  • opencode version: v2.0.27 (latest channel)
  • OS: Darwin 25.6.0 (darwin arm64), macOS MacBook Pro
  • Terminal: Ghostty (TERM_PROGRAM=ghostty, TERM=xterm-ghostty, COLORTERM=truecolor)
  • Shell: /bin/zsh
  • Install/channel: latest release
  • Active plugins: none found in config

Reproduction

  1. opencode service set hostname 0.0.0.0 then opencode service start.
  2. Run opencode pair.
  3. Observe the output: two links are printed — one to http://127.0.0.1:<port>/auth/connect/... and one to http://<lan-ip>:<port>/auth/connect/....
  4. Scan the QR code with a phone on the same LAN (or decode it).

Expected Behavior

The QR code should encode the link reachable from other devices — i.e., the LAN IP link when bound to 0.0.0.0. At minimum, it should not encode the loopback address, which is unreachable by definition from any remote device.

Actual Behavior

The QR encodes http://127.0.0.1:<port>/auth/connect/.... Scanning it with a phone opens a page on the phone itself and fails; the user must manually retype the second printed URL to pair.

Sample output (token redacted):

Open a link to connect. Links work once and expire in 5 minutes.

  http://127.0.0.1:49374/auth/connect/MG_...
  http://192.168.x.x:49374/auth/connect/MG_...

Additional Context

  • Consistently reproducible whenever the service is bound to a non-loopback hostname.
  • Workaround that confirms intent: opencode pair --url http://<lan-ip>:<port> prints only the LAN link, and the QR then encodes it correctly — so the fix likely just needs the default QR payload to prefer the non-loopback link when multiple are printed.
Ngôn ngữ chính
TypeScript
Star
213k
Fork
28.4k
Merge trung bình
8 giờ 51 phút
Pull request đã merge (30 ngày)
289

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của anomalyco/opencode

Tất cả issue của anomalyco/opencode

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.