File size: 3,704 Bytes
0dbc9de | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | ---
title: Web
description: ๋ธ๋ผ์ฐ์ ์์ OpenCode ์ฌ์ฉํ๊ธฐ.
---
opencode๋ ๋ธ๋ผ์ฐ์ ์์ ์น ์์ฉ ํ๋ก๊ทธ๋จ์ ์คํํ ์ ์์ผ๋ฉฐ terminal์ ํ์๋กํ์ง ์๊ณ ๋์ผํ ๊ฐ๋ ฅํ AI ์ฝ๋ฉ ๊ฒฝํ์ ์ ๊ณตํฉ๋๋ค.

## ์์ํ๊ธฐ
์คํํ์ฌ ์น ์ธํฐํ์ด์ค๋ฅผ ์์:
```bash
opencode web
```
`127.0.0.1`์ ๋ก์ปฌ ์๋ฒ๋ฅผ ๋๋ค ์ฌ์ฉ ๊ฐ๋ฅํ ํฌํธ๋ก ์์ํ๊ณ ๊ธฐ๋ณธ ๋ธ๋ผ์ฐ์ ์์ opencode๋ฅผ ์๋์ผ๋ก ์ฝ๋๋ค.
:::caution
`OPENCODE_SERVER_PASSWORD`๊ฐ ์ค์ ๋์ง ์์ ๊ฒฝ์ฐ ์๋ฒ๊ฐ ์ค๋จ๋์ง ์์ต๋๋ค. ์ด๊ฒ์ ๋ก์ปฌ ์ฌ์ฉ์์ํ ๊ด์ฐฎ์ง๋ง ๋คํธ์ํฌ ์ก์ธ์ค๋ฅผ ์ค์ ํด์ผํฉ๋๋ค.
:::
:::tip[Windows ์ฌ์ฉ์]
์ต๊ณ ์ ๊ฒฝํ์ ์ํด์๋ PowerShell๋ณด๋ค `opencode web`๋ฅผ ์คํํ์ญ์์ค. ์ ์ ํ ํ์ผ ์์คํ
์ก์ธ์ค ๋ฐ terminal ํตํฉ์ ๋ณด์ฅํฉ๋๋ค.
:::
---
## ๊ตฌ์ฑ
๋ช
๋ น์ค ํ๋๊ทธ ๋๋ [config file](/docs/config)์์ ์น ์๋ฒ๋ฅผ ๊ตฌ์ฑํ ์ ์์ต๋๋ค.
## ํฌํธ
๊ธฐ๋ณธ์ ์ผ๋ก opencode๋ ์ฌ์ฉํ ์ ์๋ ํฌํธ๋ฅผ ์ ํํฉ๋๋ค. ํฌํธ๋ฅผ ์ง์ ํ ์ ์์ต๋๋ค:
```bash
opencode web --port 4096
```
## ํธ์คํธ ์ด๋ฆ
๊ธฐ๋ณธ์ ์ผ๋ก ์๋ฒ๋ `127.0.0.1` (localhost only)์ ๋ฐ์ธ๋ฉํฉ๋๋ค. ๋คํธ์ํฌ์์ opencode๋ฅผ ์ฌ์ฉํ ์ ์๋๋ก:
```bash
opencode web --hostname 0.0.0.0
```
`0.0.0.0`๋ฅผ ์ฌ์ฉํ ๋, opencode๋ ๋ก์ปฌ ๋ฐ ๋คํธ์ํฌ ์ฃผ์๋ฅผ ๋ชจ๋ ํ์ํฉ๋๋ค.
```
Local access: http://localhost:4096
Network access: http://192.168.1.100:4096
```
### mDNS ๋ฐ๊ฒฌ
๋ก์ปฌ ๋คํธ์ํฌ์์ ์๋ฒ๋ฅผ ๋ฐ๊ฒฌํ ์ ์๋ mDNS:
```bash
opencode web --mdns
```
์ด ์๋์ผ๋ก `0.0.0.0`์ hostname์ ์ค์ ํ๊ณ `opencode.local`๋ก ์๋ฒ๋ฅผ ๊ด๊ณ ํฉ๋๋ค.
๋์ผํ ๋คํธ์ํฌ์์ ์ฌ๋ฌ ์ธ์คํด์ค๋ฅผ ์คํํ๋ ค๋ฉด mDNS ๋๋ฉ์ธ ์ด๋ฆ์ ์ง์ ํ ์ ์์ต๋๋ค.
```bash
opencode web --mdns --mdns-domain myproject.local
```
###### CORS
CORS์ ๋ํ ์ถ๊ฐ ๋๋ฉ์ธ์ ํ์ฉํ๋ ค๋ฉด (์ฌ์ฉ์ ์ ์ frontends์ ์ ํฉ) :
```bash
opencode web --cors https://example.com
```
### ์ธ์ฆ
์ก์ธ์ค๋ฅผ ๋ณดํธํ๋ ค๋ฉด `OPENCODE_SERVER_PASSWORD` ํ๊ฒฝ ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ์ํธ๋ฅผ ์ค์ ํ์ญ์์ค.
```bash
OPENCODE_SERVER_PASSWORD=secret opencode web
```
`opencode`์ ๋ํ ์ฌ์ฉ์์ ๊ธฐ๋ณธ๊ฐ์ `OPENCODE_SERVER_USERNAME`๋ก ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
---
## ์น ์ธํฐํ์ด์ค ์ฌ์ฉ
์์๋๋ฉด ์น ์ธํฐํ์ด์ค๋ opencode ์ธ์
์ ์ก์ธ์ค ํ ์ ์์ต๋๋ค.
## ์ธ์
ํํ์ด์ง์์ ์ธ์
์ ๋ณด๊ณ ๊ด๋ฆฌํฉ๋๋ค. ํ์ฑ ์ธ์
์ ๋ณผ ์ ์์ผ๋ฉฐ ์๋ก์ด ๊ฒ์ ์์ํฉ๋๋ค.

## ์๋ฒ ์ํ
"See Servers"๋ฅผ ํด๋ฆญํ์ฌ ์ฐ๊ฒฐ๋ ์๋ฒ์ ์ํ๋ฅผ ๋ณผ ์ ์์ต๋๋ค.

---
## ํฐ๋ฏธ๋ ์ฐ๊ฒฐ
์คํ ์น ์๋ฒ์ terminal TUI๋ฅผ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค.
```bash
# Start the web server
opencode web --port 4096
# In another terminal, attach the TUI
opencode attach http://localhost:4096
```
์น ์ธํฐํ์ด์ค์ terminal์ ๋์์ ์ฌ์ฉํ ์ ์๋๋ก, ๊ฐ์ ์ธ์
๊ณผ ์ํ๋ฅผ ๊ณต์ ํฉ๋๋ค.
---
## ๊ตฌ์ฑ ํ์ผ
`opencode.json` config ํ์ผ์์ ์๋ฒ ์ค์ ์ ๊ตฌ์ฑํ ์ ์์ต๋๋ค:
```json
{
"server": {
"port": 4096,
"hostname": "0.0.0.0",
"mdns": true,
"cors": ["https://example.com"]
}
}
```
Command line flags๋ config ํ์ผ ์ค์ ์ ๋ํ precedence๋ฅผ ๊ฐ์ ธ์ต๋๋ค.
|