่ฟๆฏไธไธช้ขๅๆๆบๆต่งๅจใๅฏ่ชๆ็ฎกๅฐๆๅกๅจๆๅฑๅ็ฝ็ OpenCode Web ๅฎขๆท็ซฏไธ้จ็ฝฒ็ฝๅ ณ๏ผๆไพไผ่ฏๅ่กจใๆตๅผๅๅคใMarkdownใๅทฅๅ ท่ฐ็จๅฑ็คบใๆไปถไธไผ ๅ็งปๅจ็ซฏๆฝๅฑๅผๅฏผ่ชใๅฎๅฑไบ OpenCode ็ๆ๏ผๆขๅฏไปฅๅจ Windows ็ต่ไธๅฏๅจไพๆๆบ้่ฟๅฑๅ็ฝ่ฎฟ้ฎ๏ผไนๅฏไปฅ้จ็ฝฒๅฐ Linux ๆๅกๅจๅนถ้่ฟๅๅๅฏนๅคๆไพ HTTPS ๆๅกใ
ๆฌๆๆกฃๆไพๅฎๆด็ไธญๆ่ฏดๆๅๅฎๆด็ English documentation๏ผ่ฑๆๆๆกฃไฝไบไธๆนใ
| ไธป็้ข | ไผ่ฏๅ่กจ๏ผ็นๅผ โฐ ่ๅ๏ผ |
|---|---|
![]() |
![]() |
- ็งปๅจ็ซฏไผๅ ็ๆทฑ่ฒ็้ข๏ผๆฏๆๆๆบๅฎๅ จๅบๅใ
- ไผ่ฏๅๆขใๅๅฒๆถๆฏ็ผๅญๅๆธธๆ ๅ้กตๅ ่ฝฝใ
- ้่ฟ OpenCode ไบไปถๆฅๅฃๅฎๆถๆพ็คบ็ๆๅ ๅฎน๏ผSSE ไธๅฏ็จๆถไฝฟ็จ่ฝฎ่ฏขๅๆญฅ็ถๆๅๆถๆฏใ
- SSE ๅ ผๅฎน LF/CRLF ๅ้็ฌฆ๏ผ็ๆไธญ็ๆๆฌๅๆ่ๅ ๅฎนไผ้ๅๆพ็คบใ
- ๆฏๆ้ๆฉๆจกๅใAgent ๅๆ่ๅผบๅบฆ๏ผvariant๏ผ๏ผๅนถๆๆจกๅไฟๅญ้ๆฉ๏ผๅๆขไผ่ฏๆถๆจกๅ้ๆฉๅจไผ่ชๅจๅๆญฅๅฐ่ฏฅไผ่ฏๅฝๅๅฎ้ ไฝฟ็จ็ๆจกๅใๆจกๅๅ่กจไผๆ ๆณจๅๆจกๅๆฏๆ็ๆจกๆ๏ผ๐ผ๏ธ ๅพๅใ๐๏ธ ้ณ้ขใ๐ฌ ่ง้ขใ๐ ๆๆกฃ๏ผ๏ผ็บฏๆๆฌๆจกๅๆพ็คบโ็บฏๆๆฌโใ
- ๆฏๆๆพ็คบๅฝๅไผ่ฏ็ไธไธๆ็จ้ๅๆจกๅไธไธๆไธ้ใ
- ๆฏๆๅค็ OpenCode ็ AI ่ฟฝ้ฎ๏ผๅฏๅ้ใๅค้ใ่ชๅฎไนๅ็ญๆ่ทณ่ฟใ
- ๆฏๆๅๆฌก่ฏทๆฑๆๅค 20 MB ็ๆไปถ้ไปถ๏ผๅฏๆๆไปถๆๅพ็็ดๆฅๆ่ฟ่พๅ ฅๆกใ
- ไพง่พนๆ ็ดๆฅ็ฎก็ๅ provider ็ API ๅฏ้ฅ๏ผๅๆขๅ่ชๅจ้ๅฏ OpenCode ๆๅก็ๆใ
- ๆฏๆๅๆญข็ๆใ้่ฏ็ถๆๆ็คบใไปฃ็ ๅๅคๅถๅ็งปๅจ็ซฏ PWA ๅฎ่ฃ ๅ ฅๅฃใ
- ๅ็ซฏๆ ้ๆๅปบ๏ผ่ฟ่กๆถๆ ้ๅฎ่ฃ npm ไพ่ตใ
- Node ็ฝๅ
ณๅๆถๆไพ้ๆ้กต้ข๏ผๅนถไปฃ็
/opencode/api/*ๅฐ OpenCode ๆๅกใ
ๆๆบๆ็ต่ๆต่งๅจ
-> /opencode/ ๆๆบ Web ้กต้ข
-> /opencode/api/* Node ็ฝๅ
ณ
-> 127.0.0.1:4096 OpenCode ๆๅก
ๆฌ้กน็ฎๆฏ OpenCode ็ๅฎขๆท็ซฏๅ็ฝๅ
ณ๏ผไธๅ
ๅซ OpenCode CLI ๆฌ่บซใไฝฟ็จๅ้่ฆๅ็ฌๅฎ่ฃ
OpenCode๏ผๅนถ็กฎไฟ opencode serve ๅฏไปฅ่ฟ่กใ
ๆฐ็ๅฎขๆท็ซฏไพ่ต OpenCode ็ providerใAgentใไบไปถใ้ฎ้ขๅๆธธๆ ๅ้กตๆฅๅฃใ่ฅ OpenCode ็ๆฌ่ฟๆง๏ผๅฏ่ฝๅบ็ฐๆจกๅๅ่กจไธบ็ฉบใAI ่ฟฝ้ฎๆ ๆณๆพ็คบๆโๅ ่ฝฝๆดๆฉๆถๆฏโๅคฑ่ดฅ๏ผ่ฏทไฝฟ็จไธๅฝๅ OpenCode API ๅน้ ็็ๆฌใ
Linux ๆๅกๅจๅชไฟ็ไธไปฝ Web ้กน็ฎ๏ผ
/opt/opencode-mobile-server/ ๆฌ้กน็ฎๆบ็ ใ้กต้ขๅ Node ็ฝๅ
ณ
/etc/opencode-mobile-server/opencode.env ๅฏ็ ็ญ่ฟ่ก้
็ฝฎ
/root/.opencode/ OpenCode CLI ๆฌ่บซ
Nginx ๅช่ด่ดฃๅๅใHTTPS ๅ /opencode/ ๅๅไปฃ็๏ผไธๅไป /www/wwwroot ๅคๅถๆ่ฏปๅๅ็ซฏๆไปถใ่ฟๆ ท Windows ๅ Linux ไฝฟ็จๅไธไธช้กน็ฎ็ฎๅฝ็ปๆ๏ผๅ็บงๆถๅช้่ฆๆดๆฐ /opt/opencode-mobile-serverใ้กน็ฎๆไพ็ Nginx ๆจกๆฟ้ป่ฎคๅช็ๅฌ HTTP 80 ็ซฏๅฃ๏ผ่ฏไนฆๅ 443 ้
็ฝฎไป้ๅ็ฌๅฎๆใ
ๆฐ้จ็ฝฒ็้ป่ฎคๅฏ็ ๆฏ๏ผ
opencode
ๅฏนๅค็ฝๅผๆพๅๅฟ
้กปไฟฎๆนๅฏ็ ใๅคๅถ .env.example ไธบ .env๏ผไฟฎๆนไธ้ข็้
็ฝฎ๏ผ
OPENCODE_SERVER_PASSWORD=่ฏทๆฟๆขไธบ้ๆบ้ฟๅฏ็ ็ฝๅ ณๅ OpenCode ๆๅกๅฟ ้กปไฝฟ็จๅไธไธชๅฏ็ ๏ผ
- Windows๏ผไฟฎๆน้กน็ฎๆ น็ฎๅฝ็
.envใ - Linux ๆๅกๅจ๏ผไฟฎๆน
/etc/opencode-mobile-server/opencode.envใ
ๆๆบ้กต้ขไผๅฐ่พๅ
ฅ็ๅฏ็ ไฟๅญๅจๆต่งๅจๆฌๅฐๅญๅจไธญใๆนๅฏ็ ๅ๏ผ่ฏท็นๅป้กต้ข้็โ้ๅบ็ปๅฝโ้ๆฐ่พๅ
ฅ๏ผๅฆๆไป็ถๅคฑ่ดฅ๏ผ่ฏทๆธ
้ค่ฏฅ็ฝ็ซ็ๆฌๅฐๅญๅจไธญ็ oc_pwdใ
็ฝๅ
ณไฝฟ็จ Basic Auth ็ๅฏ็ ้จๅๆ ก้ช่ฎฟ้ฎๅฏ็ ๏ผ็จๆทๅไธไผ็จไบๆๆใๆฐ็็ฝๅ
ณไผๅ
ๆ ก้ช /opencode/api/*๏ผๅ่ฝฌๅ็ป OpenCode๏ผOpenCode ๆๅกไปๅฟ
้กปไฝฟ็จ็ธๅๅฏ็ ใ
- Windows 10 ๆๆด้ซ็ๆฌใ
- Node.js 18 ๆๆด้ซ็ๆฌใ
- ๅทฒๅฎ่ฃ
OpenCode๏ผไธๅฝไปค่กๅฏไปฅ็ดๆฅๆง่ก
opencodeใ
ๅฐ็ฝ็จๆท่ฏทๅ
้
่ฏปๅฎๆด็ Windows ๅฑๅ็ฝ่ฎฟ้ฎๆๅ๏ผๅ
ถไธญ่งฃ้ไบ 127.0.0.1ใ0.0.0.0 ๅ 192.168.x.x ็ๅบๅซใ
ๆจ่็ดๆฅๅๅปไธ้ข็ๆไปถ่ฟ่กไธ้ฎ้จ็ฝฒ๏ผ
scripts\deploy-windows.bat
ๅฎไผๆฃๆฅ Node.js ๅ OpenCode๏ผ่ชๅจๅๅปบ .env๏ผๅฏๅจ OpenCode ๅ Web ็ฝๅ
ณ๏ผๅนถๆๅผๆฌๆบ้กต้ขใ้ฆๆฌกๅฏๅจๅ่ฏท็ผ่พ้กน็ฎๆ น็ฎๅฝ็ .env ไฟฎๆนๅฏ็ ๏ผๅ้ๆฐ่ฟ่ก่ๆฌใ
ๅฆๆ 4096 ็ซฏๅฃๅทฒๆ OpenCode ๆๅก๏ผ่ๆฌไผๅค็จๅฎ๏ผ้ๅธธๅช้่ฆๅฏๅจ็ชๅฃๅ Web ็ฝๅ ณ็ชๅฃ๏ผๅฆๆ่ๆฌ้่ฆๆฐๅฏๅจ OpenCode๏ผๅฏ่ฝไผ้ขๅคๅบ็ฐไธไธชๅ็ซฏ็ชๅฃใๅฆๆๅ็ซฏๅฏๅจๅคฑ่ดฅ๏ผWeb ็ฝๅ ณ PowerShell ็ชๅฃไผไฟ็้่ฏฏไฟกๆฏ๏ผไธ่ฆๅช็่ชๅจๅ ณ้ญ็ๅ็ซฏ็ชๅฃใ
ๅจ PowerShell ไธญ่ฟๅ ฅ้กน็ฎ็ฎๅฝ๏ผ
Copy-Item .env.example .env
notepad .env
powershell -ExecutionPolicy Bypass -File .\scripts\start-windows.ps1่ๆฌไผๅฏๅจ๏ผ
- OpenCode API๏ผ
127.0.0.1:4096๏ผๅชๅ ่ฎธๆฌๆบ่ฎฟ้ฎใ - Web ็ฝๅ
ณ๏ผ
0.0.0.0:8787๏ผๅ ่ฎธๅฑๅ็ฝ่ฎฟ้ฎใ
ไฝฟ็จ ipconfig ๆฅ็ Windows ็ๅฑๅ็ฝ IP๏ผไพๅฆ 192.168.1.100๏ผ็ถๅๅจๆๆบๆต่งๅจๆๅผ๏ผ
http://192.168.1.100:8787/opencode/
ๅฆๆ Windows ้ฒ็ซๅขๆฆๆช 8787 ็ซฏๅฃ๏ผ่ฏทไฝฟ็จ็ฎก็ๅ PowerShell ๆง่ก๏ผ
New-NetFirewallRule -DisplayName "OpenCode Mobile Server" -Direction Inbound -Protocol TCP -LocalPort 8787 -Action Allowๅฆๆ OpenCode ๅทฒ็ปไฝไธบๅ ถไปๆๅก่ฟ่ก๏ผๅชๅฏๅจ Web ็ฝๅ ณ๏ผ
powershell -ExecutionPolicy Bypass -File .\scripts\start-windows.ps1 -SkipBackend- Linuxใsystemd ๅ Nginxใ
- Node.js 18 ๆๆด้ซ็ๆฌใ
- OpenCode ๅทฒๅฎ่ฃ
ใ็คบไพๆๅกๆไปถ้ป่ฎคไฝฟ็จ
/usr/local/bin/opencode๏ผ่ฏทๆๅฎ้ ๅฎ่ฃ ่ทฏๅพไฟฎๆนใ - ๅๅ็ DNS
AๆAAAA่ฎฐๅฝๅทฒ็ปๆๅๆๅกๅจใ
ๅฐ้กน็ฎๆพๅฐ /opt/opencode-mobile-server๏ผๅๅปบๆๅกๅจ้
็ฝฎๆไปถ๏ผ
sudo mkdir -p /opt/opencode-mobile-server
sudo cp -a . /opt/opencode-mobile-server/
sudo mkdir -p /etc/opencode-mobile-server
sudo cp /opt/opencode-mobile-server/.env.example /etc/opencode-mobile-server/opencode.env
sudo chmod 600 /etc/opencode-mobile-server/opencode.env
sudo editor /etc/opencode-mobile-server/opencode.env
NODE_BIN="$(command -v node)"
sudo sed -e "s|__INSTALL_DIR__|/opt/opencode-mobile-server|g" -e "s|__NODE_BIN__|${NODE_BIN}|g" /opt/opencode-mobile-server/scripts/opencode-mobile-server.service | sudo tee /etc/systemd/system/opencode-mobile-server.service >/dev/null
sudo systemctl daemon-reload
sudo systemctl enable --now opencode-mobile-server.serviceๆจ่ไฝฟ็จไธ้ข็ Linux ไธ้ฎ้จ็ฝฒ่ๆฌใๅฎไผๅฎ่ฃ Web ็ฝๅ ณๅ OpenCode systemd ๆๅก๏ผไผ ๅ ฅๅๅๅ่ฟไผ็ๆๅนถๆฃๆฅ Nginx ้ ็ฝฎ๏ผ
sudo bash scripts/deploy-linux.sh example.comๅฆๆๅช้่ฆๅฎ่ฃ ๆๅกใไธ่ชๅจๅๅ ฅ Nginx๏ผ
sudo bash scripts/deploy-linux.sh --skip-nginxๅฆๆ OpenCode ไธๅจ PATH ไธญ๏ผๅฏไปฅๆๅฎไบ่ฟๅถ่ทฏๅพ๏ผ
sudo OPENCODE_BIN=/path/to/opencode bash scripts/deploy-linux.sh example.com่ๆฌ่ฟๆฏๆไปฅไธ้้กน๏ผ
--domain=example.com๏ผ็จ้้กนๅฝขๅผๆๅฎๅๅใ--skip-nginx๏ผๅชๅฎ่ฃ ไธคไธช systemd ๆๅก๏ผไธๅๅ ฅ Nginx ้ ็ฝฎใINSTALL_DIR=/srv/opencode-mobile-server๏ผไฟฎๆน้กน็ฎๅฎ่ฃ ็ฎๅฝใ
Linux ็ฝๅ
ณๅบๅช็ๅฌๅ็ฏๅฐๅใ่ๆฌ็ๆ็ systemd ๅๅ
ไผ่ฎพ็ฝฎ OPENCODE_WEB_HOST=127.0.0.1๏ผ้จ็ฝฒๅๅฏ็จไธ้ข็ๅฝไปค็กฎ่ฎค 8787 ๆฒกๆ็ดๆฅๆด้ฒๅฐๅ
ฌ็ฝ๏ผ
sudo ss -ltnp | grep ':8787'ๅฆๆๆๅจไฟฎๆนไบ systemd ๅๅ
ๆ็ฏๅขๆไปถ๏ผ่ฏทไฟ็ OPENCODE_WEB_HOST=127.0.0.1๏ผๅๆง่ก sudo systemctl daemon-reload && sudo systemctl restart opencode-mobile-server.serviceใ
OpenCode ๆๅกๅฟ
้กปไฝฟ็จๅ /etc/opencode-mobile-server/opencode.env ็ธๅ็ๅฏ็ ใ้กน็ฎๆไพไบๅ่ๆๅกๆไปถ๏ผ
sudo cp /opt/opencode-mobile-server/scripts/opencode-server.service /etc/systemd/system/opencode-server.service
sudo editor /etc/systemd/system/opencode-server.service
sudo systemctl daemon-reload
sudo systemctl enable --now opencode-server.serviceๅฎ่ฃ
ๅ่ฏทๆฃๆฅ ExecStart ไธญ็ OpenCode ่ทฏๅพใๆๅกๅจไธ็ OpenCode API ้ป่ฎคๅช็ๅฌ 127.0.0.1:4096๏ผไธ่ฆ็ดๆฅๆด้ฒ 4096 ็ซฏๅฃใ
็ๆๆๅคๅถ scripts/nginx-opencode-mobile-server.conf.example๏ผๆ __DOMAIN__ ๆฟๆขไธบๅฎ้
ๅๅใๆจกๆฟๅฎๆ Nginx ๅฐๆฌๆบ็ฝๅ
ณ็ HTTP ๅๅไปฃ็๏ผๅๅง่ฎฟ้ฎๅฐๅๆฏ๏ผ
http://example.com/opencode/
ๆฃๆฅๅนถ้ๆฐๅ ่ฝฝ Nginx๏ผ
sudo nginx -t
sudo systemctl reload nginxๅฆๆๅๅๅทฒ็ปๆ Nginx server ๅ๏ผไธ่ฆๅๅปบ้ๅค็ server๏ผๅชๆๆจกๆฟไธญ็ /opencode ไธคไธช location ๅคๅถๅฐ็ฐๆ้
็ฝฎไธญใๅ
ฌ็ฝไฝฟ็จๆถๅฟ
้กปๅฆๅค้
็ฝฎ HTTPSใ443 ็ๅฌๅ่ฏไนฆ๏ผๅฎๆๅๅไฝฟ็จ๏ผ
https://example.com/opencode/
ๅฏไปฅไฝฟ็จ Certbot ๆๆๅกๅจๅทฒๆ็่ฏไนฆ็ฎก็ๅทฅๅ ท้ ็ฝฎ HTTPSใไธ่ฆๆ 4096 ็ซฏๅฃๆๆช็ป HTTPS ไฟๆค็ 8787 ็ซฏๅฃ็ดๆฅๆด้ฒๅฐๅ ฌ็ฝใ
ๅคๅถๅนถ็ผ่พ .env ๅๆง่ก๏ผ
npm start้ป่ฎค่ฎฟ้ฎๅฐๅ๏ผ
http://127.0.0.1:8787/opencode/
ๆฌ้กน็ฎๆฒกๆ่ฟ่กๆถ npm ไพ่ต๏ผไธ้่ฆๆง่ก npm installใ
npm run start:lan ๅชๆฏ npm start ็ๅซๅ๏ผไธไผ่ชๅจไฟฎๆน็ๅฌๅฐๅ๏ผๆฏๅฆๅ
่ฎธๅฑๅ็ฝ่ฎฟ้ฎ็ฑ OPENCODE_WEB_HOST ๅณๅฎใ
| ้ ็ฝฎ้กน | ้ป่ฎคๅผ | ่ฏดๆ |
|---|---|---|
OPENCODE_SERVER_PASSWORD |
opencode |
OpenCode Basic Auth ๅฏ็ ๏ผๅฟ ้กปไฟฎๆน |
OPENCODE_API_URL |
http://127.0.0.1:4096 |
OpenCode ๆๅกๅฐๅ |
OPENCODE_WEB_HOST |
127.0.0.1 |
Web ็ฝๅ
ณ็ๅฌๅฐๅ๏ผWindows ่ๆฌไผไฝฟ็จ 0.0.0.0 |
OPENCODE_WEB_PORT |
8787 |
Web ็ฝๅ ณ็ซฏๅฃ |
OPENCODE_SERVICE_NAME |
opencode-server.service |
ๅฏ้ฅๅๆขๅ่ชๅจ้ๅฏ็ OpenCode systemd ๆๅก๏ผ่ฎพไธบ none ๅ
ณ้ญ่ชๅจ้ๅฏ |
OPENCODE_AUTH_FILE |
่ชๅจๆฃๆต | OpenCode ็ auth.json ่ทฏๅพ๏ผLinux ไธบ ~/.local/share/opencode/auth.json๏ผmacOS ไธบ ~/Library/Application Support/opencode/auth.json๏ผWindows ไธบ %LOCALAPPDATA%\opencode\auth.json๏ผ |
OPENCODE_AUTH_KEYS_FILE |
้กน็ฎ็ฎๅฝ .auth-keys.json |
็ฝๅ
ณไฟๅญๅ
จ้จๅฏ้ฅ็ๆฌๅฐๆไปถ๏ผๅปบ่ฎฎ Linux ๆๅกๅจๆพๅฐ /etc/opencode-mobile-server/๏ผ |
ๆต่งๅจ API ่ทฏๅพๅบๅฎไธบ /opencode/api๏ผๅ ๆญคๅไธไปฝๅ็ซฏไปฃ็ ๆขๅฏไปฅ็จไบ Windows ๅฑๅ็ฝ๏ผไนๅฏไปฅ็จไบๆๅกๅจๅๅ่ทฏๅพ๏ผไธ้่ฆ้ๆฐๆๅปบใ
OPENCODE_AUTH_FILEใOPENCODE_AUTH_KEYS_FILE ๅปบ่ฎฎไฝฟ็จ็ปๅฏน่ทฏๅพใLinux ไฝฟ็จ XDG_DATA_HOME ๆถ๏ผ่ชๅจๆฃๆต็ OpenCode ๅฏ้ฅๆไปถไธบ $XDG_DATA_HOME/opencode/auth.jsonใ
้กถ้จๅฏไปฅ้ๆฉ OpenCode ่ฟๅ็ๆจกๅใAgent ๅๆ่ๅผบๅบฆใๆฏไธชๆจกๅๅ้ขไผๆพ็คบๅฎๆฏๆ็่พๅ
ฅๆจกๆ๏ผๅพๅใ้ณ้ขใ่ง้ขใๆๆกฃ๏ผไปฅๅ่พๅบๆจกๆ๏ผๅฆโ็ๆ๐ผ๏ธโ่กจ็คบๅฏไปฅ็ๆๅพๅ๏ผ๏ผๆฒกๆ้ขๅคๆจกๆ็ๆจกๅๆพ็คบโ็บฏๆๆฌโใๆจกๆไฟกๆฏๆฅ่ช OpenCode ็ provider ้
็ฝฎ๏ผOpenCode ็ๆฌ่ฟๆงๆถๅฏ่ฝไธๆพ็คบใๆ่ๅผบๅบฆๅชๅจๅฝๅๆจกๅๆฏๆๆจ็ๆถๆพ็คบ๏ผๅฏ็จๅผ็ฑๆจกๅ้
็ฝฎๅณๅฎ๏ผๅธธ่งๅผๅ
ๆฌ noneใminimalใlowใmediumใhighใmax ๅ xhighใ
ๅฝๅๆจกๅๆไพไธไธๆไธ้ๆถ๏ผๆถๆฏๅบไธๆนไผๆพ็คบๅทฒ็จ tokensใไธ้ๅ็พๅๆฏ๏ผ่พพๅฐ 70% ๆ 90% ๆถไผๆนๅๆ็คบ้ข่ฒใๅฎๆฏไผฐ็ฎๆ็คบ๏ผไธไผๆฟไปฃ OpenCode ็ๅฎ้ ้ๅถใ
ๅฝ Agent ้่ฟ OpenCode question.asked ไบไปถๆ้ฎๆถ๏ผ้กต้ขไผๆพ็คบ้ฎ้ข้ขๆฟ๏ผๆฏๆๅ้ใๅค้ใ่ชๅฎไนๆๆฌๅ่ทณ่ฟใๅ็ญๆ่ทณ่ฟๅ๏ผไปปๅกไผ็ปง็ปญๆง่ก๏ผๅๆขไผ่ฏๆถไธไผๆพ็คบๅ
ถไปไผ่ฏ็้ฎ้ขใๅฎขๆท็ซฏๅๆถๅ
ผๅฎนๆฐ็ OpenCode ไธๅ็ question.v2.* ๅ permission.v2.* ไบไปถๅใ
็ๆไธญ็ๆถๆฏ้่ฟ SSE ๅข้ๆพ็คบใ่ฟๆฅไธญๆญๆถ้กต้ขไผ่ชๅจ้่ฟ๏ผๅนถๅจ้กต้ขๅฏ่งๆถ่ฝฎ่ฏขไผ่ฏ็ถๆๅๆ่ฟๆถๆฏไฝไธบๅ ๅบใ้กถ้จ็ๅๆญขๆ้ฎไผ่ฐ็จ OpenCode ็ abort ๆฅๅฃใ
ๅๅคไฝฟ็จ่ฝป้ Markdown๏ผๆฏๆๆ ้ขใ็ฒไฝใๆไฝใๅ ้ค็บฟใ่กๅ ไปฃ็ ใไปฃ็ ๅใๅผ็จใๆ ๅบๅ่กจใ้พๆฅใ็ฎๅ่กจๆ ผๅๅ้็บฟ๏ผไธๆไพๅฎๆด Markdown ่งฃๆๆไปฃ็ ้ซไบฎใ้ไปถไผ่ฝฌๆ Data URL ๅๅ้๏ผๅๆฌกๆถๆฏ้ๆฉ็ๆไปถๅๅงๅคงๅฐๅ่ฎกๆๅค 20 MB๏ผๆฏๆ็ดๆฅๆๆไปถๆๅพ็ๆ่ฟ่พๅ ฅๆก๏ผไป ๅธฆ้ไปถไนๅฏไปฅ็ดๆฅๅ้ใๅๅไปฃ็็่ฏทๆฑไฝ้ๅถๅบๅคงไบ 20 MB๏ผ้กน็ฎ Nginx ๆจกๆฟไฝฟ็จ 50 MBใ
้กต้ขๆไพ PWA ๅฎ่ฃ ๆธ ๅ๏ผไฝไธๅ ๅซ็ฆป็บฟ็ผๅญใๅฏ็ ใๅฝๅไผ่ฏใๆจกๅใAgent ๅๆ่ๅผบๅบฆไฟๅญๅจๅฝๅๆต่งๅจ็ๆฌๅฐๅญๅจไธญ๏ผๆถๆฏๅ ๅฎนไธป่ฆๅจ้กต้ขๅ ๅญไธญ็ผๅญ๏ผๅทๆฐๅไผ้ๆฐไป OpenCode ๅ ่ฝฝใ
ไพง่พนๆ ็โ๐ ๅฏ้ฅโ้ขๆฟๅฏไปฅไฟๅญใๅๆขๅๅ ้คๅ provider๏ผๅฆ opencode-go๏ผ็ API ๅฏ้ฅ๏ผไธๅ้่ฆ็ปๅฝๆๅกๅจๆง่ก opencode auth loginใ
- ไฟๅญๅนถๅๆข๏ผๆฐๅฏ้ฅไผๅๅ
ฅ OpenCode ็
auth.jsonๅนถๆไธบๅฝๅ็ๆๅฏ้ฅใLinux ไธ็ฝๅ ณไผ่ชๅจ้ๅฏOPENCODE_SERVICE_NAMEๆๅฎ็ๆๅก่ฎฉๆฐๅฏ้ฅ็ซๅณ็ๆ๏ผ็บฆๅ ็ง้๏ผ๏ผ้กต้ขไผ่ชๅจ้่ฟ๏ผWindows ๆ่ชๅจ้ๅฏไธๅฏ็จๆถ๏ผ่ฏทๆๅจ้ๅฏ OpenCode ๅๅทๆฐ้กต้ขใ่ฅๅจๆๅกๅจ็ป็ซฏ็ดๆฅ่ฟ่กopencode๏ผไน้่ฆ้ๅฏ่ฏฅ็ป็ซฏไผ่ฏใ - ๅๆข๏ผๅฏไปฅๅจๅทฒไฟๅญ็ๅคไธชๅฏ้ฅไน้ดๆฅๅๅๆขใ
- ๅ ้ค๏ผๅชไปไฟๅญๅ่กจไธญ็งป้ค๏ผไธๅฝฑๅๅฝๅ็ๆๅฏ้ฅใ
- ๅฏ้ฅไฟๅญๅจ
OPENCODE_AUTH_KEYS_FILEๆๅฎ็ๆไปถไธญ๏ผ้ป่ฎค้กน็ฎ็ฎๅฝ.auth-keys.json๏ผๅทฒๅ ๅ ฅ.gitignore๏ผ๏ผไธไผๅๅ ฅไปๅบ๏ผๅๅ ฅauth.jsonๅไผไฟ็ไธไปฝauth.json.bakๅคไปฝใๆฅๅฃๅช่ฟๅๆฉ็ ๅๅฏ้ฅๅ ๆฐๆฎ๏ผไธไผๆๅๅงๅฏ้ฅ่ฟๅ็ป้กต้ขใ - Linux ๅปบ่ฎฎๆ
OPENCODE_AUTH_KEYS_FILEๆพๅจ/etc/opencode-mobile-server/๏ผๅนถ้ๅถไธบไป ๆๅก็จๆทๅฏ่ฏป๏ผไธ่ฆๆ.auth-keys.jsonใauth.jsonๆauth.json.bakๆพๅ ฅ Git ไปๅบๆๅคไปฝๅฐๅ ฌๅผไฝ็ฝฎใ
ๆณจๆ๏ผOpenCode ๆๅกๅจๅฏๅจๆถ่ฏปๅๅฏ้ฅๅนถ็ผๅญ๏ผๆไปฅไฟฎๆนๅฏ้ฅๅๅฟ ้กป้ๅฏๆๅกๆไผ็ๆ๏ผ่ฟๅฐฑๆฏไฟๅญ/ๅๆขๅ็ฝๅ ณ่ชๅจๆง่ก้ๅฏ็ๅๅ ใ
ๅ็บงๆถ่ฏทๅๆถๆฟๆข index.htmlใserver.mjsใpackage.json ๅ scripts/ ไธ็้จ็ฝฒๆไปถ๏ผไธ่ฆๅชๆฟๆข้กต้ขใWindows ไฟ็้กน็ฎๆ น็ฎๅฝ็ .env๏ผLinux ไฟ็ /etc/opencode-mobile-server/opencode.env ๅๅฏ้ฅๆไปถใๆฟๆขๅฎๆๅ้ๅฏ Web ็ฝๅ
ณๅ OpenCode ๆๅก๏ผ
sudo systemctl restart opencode-server.service opencode-mobile-server.serviceๅฆๆไฝฟ็จ Windows๏ผๅ
ณ้ญๆง็ PowerShell ็ฝๅ
ณ็ชๅฃๅ้ๆฐ่ฟ่ก scripts\deploy-windows.bat๏ผๆ่ฟ่ก scripts\start-windows.ps1ใๆต่งๅจไปๆพ็คบๆง้กต้ขๆถ๏ผๅ
ๅผบๅถๅทๆฐ๏ผๆจกๅใAgent ๆๆ่ๅผบๅบฆๅผๅธธๆถ๏ผๅฏๆธ
็ๆต่งๅจๆฌๅฐๅญๅจไธญ็ oc_modelใoc_agent ๅ oc_variants ๅ้ๆฐๆๅผ้กต้ขใ
ๆฃๆฅ .envใ/etc/opencode-mobile-server/opencode.env ๅ opencode serve ไฝฟ็จ็ๅฏ็ ๆฏๅฆไธ่ดใ็ถๅ้ๅบ็ปๅฝ๏ผๆๆธ
้ค็ฝ็ซๆฌๅฐๅญๅจไธญ็ oc_pwd ๅ้ๆฐ็ปๅฝใ
ๅฆๆๆต่งๅจๅผนๅบๆ ้ขไธบ Secure Area ็็จๆทๅๅๅฏ็ ๅฏน่ฏๆก๏ผ้ฃๆฏๆง็ฝๅ
ณ้ไผ ไบ OpenCode ็ WWW-Authenticate ๅๅบๅคด๏ผ่งฆๅไบๆต่งๅจๅ็ Basic Authใๅฝๅ็ฝๅ
ณไผ้่่ฟไธชๅๅบๅคด๏ผๅชๆพ็คบ้กต้ข่ชๅทฑ็็ปๅฝๆก๏ผๆดๆฐ้กต้ขๅ่ฏทๅทๆฐๆต่งๅจ็ผๅญใ
Node ็ฝๅ
ณๆ ๆณ่ฟๆฅ OPENCODE_API_URLใๆฃๆฅ OpenCode ๆฏๅฆ็ๅฌ 4096 ็ซฏๅฃ๏ผไปฅๅ้
็ฝฎๆไปถไธญ็ๅฐๅๆฏๅฆๆญฃ็กฎใ
่ฏทๅทๆฐ้กต้ข่ทๅๆๆฐ็ index.htmlใๅฎขๆท็ซฏไผๆ SSE ๆ ๅๅๆถ่งฃๆ LF ๅ CRLF ไบไปถๅ้็ฌฆ๏ผ็ฝๅ
ณๅ Nginx ไนไผๅฏนไบไปถๆตๅ
ณ้ญ็ผๅญๅๅ
ๅฎน่ฝฌๆขใๅฆๆไป็ถ่ขซ็ผๅญ๏ผ่ฏท็กฎ่ฎค่ชๅฎไน Nginx ้
็ฝฎๅ
ๅซ proxy_buffering off ๅ proxy_cache offใ
้กถ้จโๆ่โ้ๆฉๅจไผๅจๅฝๅๆจกๅๆฏๆๆจ็ๆถๆพ็คบใๅฎไผ ้ OpenCode ็ variant ๅๆฐ๏ผๅธธ่ง้้กนๅ
ๆฌ noneใminimalใlowใmediumใhighใmax ๅ xhigh๏ผๅ
ทไฝๅฏ็จ้้กนไปฅๆจกๅๅ OpenCode ็ๆฌไธบๅใ้ๆฉไผๆๆจกๅไฟๅญๅจๆต่งๅจๆฌๅฐใ
่ฏทไฝฟ็จๅธฆ็ปๅฐพๆๆ ็ๅฎๆด่ทฏๅพใ็ฝๅ
ณไผ่ชๅจๅฐ / ๅ /opencode ้ๅฎๅๅฐ /opencode/ใ
ๆฐ็ๅฎขๆท็ซฏไฝฟ็จ OpenCode ๅ้กตๆฅๅฃ่ฟๅ็ X-Next-Cursor ๆธธๆ ใๅฆๆๅๅ็บง่ฟ๏ผ่ฏทๅทๆฐ้กต้ข๏ผ้ฟๅ
ๆต่งๅจ็ปง็ปญไฝฟ็จๆง็ index.html ็ผๅญใ
็กฎ่ฎค OpenCode ็ๆฌๆไพ /config/providersใ/agentใ/questionใ/session/status ๅไบไปถๆฅๅฃ๏ผๅนถๆฃๆฅ็ฝๅ
ณๆฅๅฟใๅ็บง้กต้ขๅๅผบๅถๅทๆฐ๏ผๅฆๆๅชๆๆไธชๆจกๅๆฒกๆๆ่้ๆฉๅจ๏ผ้ๅธธๆฏ่ฏฅๆจกๅๆฒกๆ้
็ฝฎๆจ็่ฝๅๆ variantsใ
/opencode/api/* ๆฏ API ๅฐๅ๏ผไธๆฏ็ฝ้กต็ปๅฝ้กตใ่ฏทๆฑๅฟ
้กปๆบๅธฆ็ฝๅ
ณๅฏ็ ๅฏนๅบ็ Basic Auth๏ผๆต่งๅจๅบ่ฎฟ้ฎ /opencode/๏ผ็ฑ้กต้ขๆพ็คบ็ปๅฝๆกใไธ่ฆๆ OPENCODE_API_URL ๆๅไธไธชๆฒกๆ่ฎค่ฏใๅดๅๅฏ่ขซๅ
ฌ็ฝ่ฎฟ้ฎ็ๅ็ซฏใ
- ้ป่ฎคๅฏ็ ๅช็จไบ้ฆๆฌกๅฏๅจ๏ผๅค็ฝ้จ็ฝฒๅๅฟ ้กปไฟฎๆนใ
- ๆๅกๅจไธไฟๆ 4096 ๅช็ๅฌๅ็ฏๅฐๅใ
- Linux ็ฝๅ
ณๅช็ๅฌ
127.0.0.1๏ผ็ฑ Nginx ่ด่ดฃๅ ฌ็ฝๅ ฅๅฃ๏ผWindows ๅฑๅ็ฝไฝฟ็จ0.0.0.0ๆถๅชๅผๆพๅฏไฟก็ฝ็ปใ - ๅ ฌ็ฝ่ฎฟ้ฎๅฟ ้กปๅฏ็จ HTTPSใ
- ไธ่ฆๆ
.envใ.auth-keys.jsonใOpenCodeauth.jsonใAPI ๅฏ้ฅๆๅ ถไปๅญๆฎๆไบคๅฐ GitHub๏ผๅชๆไบค.env.exampleใ - ๅ
ฌ็ฝ้จ็ฝฒไธ่ฆไฝฟ็จ
--skip-nginxๅ็ดๆฅๆด้ฒ 8787๏ผๅ ้ ็ฝฎ HTTPS ๅๅๅไปฃ็ใ
This is a self-hosted mobile web client and deployment gateway for the OpenCode ecosystem. It provides a session list, streaming replies, Markdown rendering, tool-call display, file uploads, and a mobile drawer navigation. You can run it on a Windows computer for phone access over your LAN, or deploy it to a Linux server and expose it with a domain over HTTPS.
- Mobile-first dark interface with safe-area support.
- Session switching with cached history and cursor-based pagination.
- Live generation updates through the OpenCode event API, with polling fallback when SSE is unavailable.
- Model, Agent, and per-model reasoning-variant selection; when you switch sessions the model selector follows the model actually in use by that session. The model list shows each model's supported modalities (๐ผ๏ธ image, ๐๏ธ audio, ๐ฌ video, ๐ document); text-only models are labeled "็บฏๆๆฌ".
- Context usage display when the current model reports a context limit.
- OpenCode AI question prompts with single-choice, multiple-choice, custom answers, and skip.
- File attachments up to 20 MB per request; files or images can be dropped straight onto the input box.
- Manage provider API keys from the drawer; the gateway restarts OpenCode so the new key takes effect.
- Stop-generation control, retry notifications, code-block copy, and a mobile PWA install entry point.
- No frontend build step and no runtime npm dependencies.
- A Node gateway serves the static page and proxies
/opencode/api/*to OpenCode.
Phone or desktop browser
-> /opencode/ mobile web page
-> /opencode/api/* Node gateway
-> 127.0.0.1:4096 OpenCode server
This project is an OpenCode client and gateway. It does not include or replace the OpenCode CLI. Install OpenCode separately and make sure opencode serve is available.
The current client expects OpenCode provider, Agent, event, question, and cursor-pagination endpoints. With an older OpenCode API, the model list may be empty, AI questions may not appear, or loading older messages may fail. Use a version compatible with the current OpenCode API.
Linux keeps one Web project directory:
/opt/opencode-mobile-server/ project files and Node gateway
/etc/opencode-mobile-server/opencode.env password and runtime settings
/root/.opencode/ OpenCode CLI itself
Nginx is responsible for the domain, HTTPS, and reverse-proxying /opencode/. It no longer serves a second frontend copy from /www/wwwroot. Windows and Linux therefore use the same project layout. The included Nginx template listens on HTTP port 80 only; certificates and port 443 still need to be configured separately.
The default password for a new installation is:
opencode
Change it before exposing the service to the Internet. Copy .env.example to .env and edit:
OPENCODE_SERVER_PASSWORD=replace-with-a-random-long-passwordThe gateway and the OpenCode server must use the same password:
- Windows: edit
.envin the project root. - Linux server: edit
/etc/opencode-mobile-server/opencode.env.
The mobile page stores the entered password in browser local storage. After changing the password, use the logout button to sign in again. If that does not work, clear the site's oc_pwd local-storage value.
The gateway validates the password portion of Basic Auth for every /opencode/api/* request before proxying it to OpenCode. The OpenCode service must still use the same password; the Basic Auth username is not used for authorization.
- Windows 10 or newer.
- Node.js 18 or newer.
- OpenCode installed and available as the
opencodecommand.
For a beginner-friendly explanation of 127.0.0.1, 0.0.0.0, and 192.168.x.x, read the full Windows LAN Access Guide.
For a one-click Windows deployment, double-click:
scripts\deploy-windows.bat
It checks Node.js and OpenCode, creates .env when needed, starts OpenCode and the web gateway, and opens the local page. Edit the project-root .env after the first run to change the password, then run the script again.
If OpenCode is already listening on port 4096, the script reuses it and normally only the launcher and web-gateway windows are needed. If the script starts OpenCode itself, an additional backend window may appear. If the backend fails, the web-gateway PowerShell window keeps the error message instead of hiding it in a closed window.
Open PowerShell in the project directory:
Copy-Item .env.example .env
notepad .env
powershell -ExecutionPolicy Bypass -File .\scripts\start-windows.ps1The script starts:
- OpenCode API:
127.0.0.1:4096, accessible only from the Windows machine. - Web gateway:
0.0.0.0:8787, accessible from the LAN.
Run ipconfig to find the Windows LAN address. For example, if it is 192.168.1.100, open this URL on your phone:
http://192.168.1.100:8787/opencode/
If Windows Firewall blocks port 8787, run PowerShell as Administrator:
New-NetFirewallRule -DisplayName "OpenCode Mobile Server" -Direction Inbound -Protocol TCP -LocalPort 8787 -Action AllowIf OpenCode is already running as a separate service, start only the web gateway:
powershell -ExecutionPolicy Bypass -File .\scripts\start-windows.ps1 -SkipBackend- Linux with systemd and Nginx.
- Node.js 18 or newer.
- OpenCode installed. The example service uses
/usr/local/bin/opencode; adjust it to the actual path. - An
AorAAAADNS record pointing your domain to the server.
Copy the project to /opt/opencode-mobile-server and create the server environment file:
sudo mkdir -p /opt/opencode-mobile-server
sudo cp -a . /opt/opencode-mobile-server/
sudo mkdir -p /etc/opencode-mobile-server
sudo cp /opt/opencode-mobile-server/.env.example /etc/opencode-mobile-server/opencode.env
sudo chmod 600 /etc/opencode-mobile-server/opencode.env
sudo editor /etc/opencode-mobile-server/opencode.env
NODE_BIN="$(command -v node)"
sudo sed -e "s|__INSTALL_DIR__|/opt/opencode-mobile-server|g" -e "s|__NODE_BIN__|${NODE_BIN}|g" /opt/opencode-mobile-server/scripts/opencode-mobile-server.service | sudo tee /etc/systemd/system/opencode-mobile-server.service >/dev/null
sudo systemctl daemon-reload
sudo systemctl enable --now opencode-mobile-server.serviceFor a one-click Linux deployment, run the following script. It installs the web gateway and OpenCode systemd services. When you pass a domain, it also generates and checks the Nginx configuration:
sudo bash scripts/deploy-linux.sh example.comTo install the services without writing an Nginx configuration:
sudo bash scripts/deploy-linux.sh --skip-nginxIf OpenCode is not in PATH, provide its binary path:
sudo OPENCODE_BIN=/path/to/opencode bash scripts/deploy-linux.sh example.comThe script also supports:
--domain=example.comto provide the domain as an option.--skip-nginxto install only the two systemd services.INSTALL_DIR=/srv/opencode-mobile-serverto change the installation directory.
The Linux gateway should bind only to the loopback address. The generated systemd unit sets OPENCODE_WEB_HOST=127.0.0.1. After deployment, verify that port 8787 is not exposed directly:
sudo ss -ltnp | grep ':8787'If you edit the systemd unit or environment file, keep OPENCODE_WEB_HOST=127.0.0.1, then run sudo systemctl daemon-reload && sudo systemctl restart opencode-mobile-server.service.
The OpenCode service must use the same password as /etc/opencode-mobile-server/opencode.env. A reference service file is included:
sudo cp /opt/opencode-mobile-server/scripts/opencode-server.service /etc/systemd/system/opencode-server.service
sudo editor /etc/systemd/system/opencode-server.service
sudo systemctl daemon-reload
sudo systemctl enable --now opencode-server.serviceReview the OpenCode path in ExecStart before installing the service. The OpenCode API should listen on 127.0.0.1:4096; do not expose port 4096 directly to the Internet.
Use scripts/nginx-opencode-mobile-server.conf.example and replace __DOMAIN__ with your actual domain. The template creates an HTTP reverse proxy to the local gateway. The initial URL is:
http://example.com/opencode/
Test and reload Nginx:
sudo nginx -t
sudo systemctl reload nginxIf the domain already has an Nginx server block, do not create a duplicate one. Copy only the two /opencode locations from the template into the existing block. For public access, configure HTTPS, port 443, and a certificate separately with Certbot or your existing certificate manager. Then use:
https://example.com/opencode/
Do not expose port 4096 or an unprotected port 8787 directly to the Internet.
Copy and edit .env, then run:
npm startThe default local URL is:
http://127.0.0.1:8787/opencode/
There are no runtime npm dependencies, so npm install is not required.
npm run start:lan is only an alias for npm start; it does not change the bind address. Set OPENCODE_WEB_HOST explicitly when LAN access is needed.
| Variable | Default | Description |
|---|---|---|
OPENCODE_SERVER_PASSWORD |
opencode |
OpenCode Basic Auth password; change it |
OPENCODE_API_URL |
http://127.0.0.1:4096 |
OpenCode server address |
OPENCODE_WEB_HOST |
127.0.0.1 |
Web gateway bind address; Windows uses 0.0.0.0 |
OPENCODE_WEB_PORT |
8787 |
Web gateway port |
OPENCODE_SERVICE_NAME |
opencode-server.service |
systemd service restarted after a key switch; set to none to disable |
OPENCODE_AUTH_FILE |
auto-detected | Path to OpenCode's auth.json (Linux: ~/.local/share/opencode/auth.json, macOS: ~/Library/Application Support/opencode/auth.json, Windows: %LOCALAPPDATA%\opencode\auth.json) |
OPENCODE_AUTH_KEYS_FILE |
<project>/.auth-keys.json |
Local file where the gateway keeps all saved keys (put it under /etc/opencode-mobile-server/ on Linux servers) |
The browser API path is intentionally fixed to /opencode/api, so the same frontend works on Windows LAN and behind a domain path without rebuilding.
Use absolute paths for OPENCODE_AUTH_FILE and OPENCODE_AUTH_KEYS_FILE when possible. On Linux, automatic auth-file detection honors XDG_DATA_HOME.
The top bar can select the models, Agents, and reasoning variants returned by OpenCode. Each model name is followed by its input modalities (image, audio, video, document) and output modalities (e.g. "็ๆ๐ผ๏ธ" means it can generate images); models without extra modalities show "็บฏๆๆฌ". Modality info comes from the OpenCode provider configuration and may be absent with older OpenCode versions. The available variants depend on the model configuration and commonly include none, minimal, low, medium, high, max, and xhigh.
When the current model reports a context limit, the message area shows used tokens, the limit, and a percentage. The colors change at 70% and 90%. This is an estimate and does not replace OpenCode's own limit enforcement.
When an Agent sends an OpenCode question.asked event, the page shows a question panel with single-choice, multiple-choice, custom text, and skip actions. The task continues after an answer or skip. Questions from another session are not shown in the current session. The client also normalizes the question.v2.* and permission.v2.* event names used by newer OpenCode servers.
Messages stream through SSE. The page reconnects after a disconnect and polls session status and recent messages while visible as a fallback. The stop button calls OpenCode's abort endpoint.
Replies use lightweight Markdown: headings, bold, italics, strikethrough, inline code, code blocks, blockquotes, unordered lists, links, simple tables, and horizontal rules. It is not a full Markdown parser and does not provide syntax highlighting. Attachments are sent as Data URLs; the original files selected for one message may total at most 20 MB, and files or images can be dropped straight onto the input box; a message with only attachments can be sent directly. A reverse proxy should allow more than 20 MB for the encoded request; the included Nginx template allows 50 MB.
The page includes a PWA manifest but has no offline cache. The current browser stores the password, current session, model, Agent, and reasoning variant in local storage. Message history is primarily an in-memory cache and is loaded again from OpenCode after a refresh.
The "๐ Keys" panel in the drawer lets you save, switch, and delete provider (e.g. opencode-go) API keys from the browser โ no need to log into the server and run opencode auth login.
- Save & switch: the new key is written to OpenCode's
auth.jsonand becomes active. On Linux the gateway automatically restarts the service named byOPENCODE_SERVICE_NAMEso the key takes effect within a few seconds, and the page reconnects. On Windows, or when auto-restart is unavailable, restart OpenCode manually and refresh the page. If you also runopencodein a server terminal, restart that session too. - Switch: toggle between any saved keys at any time.
- Delete: only removes the key from the saved list; the active key is untouched.
- Keys live in the file pointed to by
OPENCODE_AUTH_KEYS_FILE(default.auth-keys.jsonin the project root, gitignored), never in the repository. Before overwritingauth.jsonaauth.json.bakbackup is kept. The API returns only masked values and metadata, not raw keys. - On Linux, put
OPENCODE_AUTH_KEYS_FILEunder/etc/opencode-mobile-server/and restrict it to the service user. Do not commit or publicly back up.auth-keys.json,auth.json, orauth.json.bak.
Note: the OpenCode server reads keys at startup and caches them, so a restart is required after a key change โ that is why the gateway restarts the service after save/switch.
Replace index.html, server.mjs, package.json, and the deployment files under scripts/ together. Keep the Windows project .env, and keep /etc/opencode-mobile-server/opencode.env plus the key files on Linux. Restart both services after replacing the files:
sudo systemctl restart opencode-server.service opencode-mobile-server.serviceOn Windows, close the old PowerShell gateway window and run scripts\deploy-windows.bat again, or run scripts\start-windows.ps1. If the browser still shows the old page, hard-refresh it. If model, Agent, or variant selection is inconsistent, clear oc_model, oc_agent, and oc_variants from browser local storage and reopen the page.
Check that the password in .env, /etc/opencode-mobile-server/opencode.env, and opencode serve is identical. Log out, or clear the site's oc_pwd local-storage value, and sign in again.
If the browser shows a Secure Area username/password dialog, an older gateway exposed OpenCode's WWW-Authenticate header and triggered the browser's native Basic Auth prompt. The current gateway hides that header and shows only the web page login form. Refresh the page after upgrading.
The Node gateway cannot reach OPENCODE_API_URL. Check that OpenCode is listening on port 4096 and that the address in .env is correct.
Use the complete path with the trailing slash. The gateway redirects / and /opencode to /opencode/.
The current client uses the X-Next-Cursor cursor returned by OpenCode's paginated message API. After an upgrade, refresh the page so the browser does not keep using an old index.html.
Confirm that the OpenCode version provides /config/providers, /agent, /question, /session/status, and the event API. Check the gateway log and hard-refresh after upgrading. If only one model lacks the reasoning selector, that model likely has no reasoning capability or variants configured.
/opencode/api/* is an API path, not the web login page. Requests must include Basic Auth with the gateway password. Open /opencode/ in a browser to use the page login form. Do not point OPENCODE_API_URL at an unauthenticated backend that is reachable from the Internet.
- The default password is for first-run convenience only. Change it before Internet access.
- Keep port 4096 bound to the loopback address on servers.
- Bind the Linux gateway to
127.0.0.1and use Nginx as the public entry point; when Windows uses0.0.0.0, allow only trusted LAN access. - Enable HTTPS for any public deployment.
- Do not commit
.env,.auth-keys.json, OpenCodeauth.json, API keys, or other credentials to GitHub. Commit only.env.example. - Do not expose port 8787 directly after using
--skip-nginx; configure HTTPS and a reverse proxy first.
MIT License. See LICENSE.

