Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

REMOTE.md

68 lines3.3 KB

1# Remote Access Setup
2​
3Use this when you want to open T3 Code from another device (phone, tablet, another laptop).
4​
5## CLI ↔ Env option map
6​
7The T3 Code CLI accepts the following configuration options, available either as CLI flags or environment variables:
8​
9| CLI flag | Env var | Notes |
10| ----------------------- | --------------------- | ------------------------------------------------------------------------------------ |
11| `--mode <web\|desktop>` | `T3CODE_MODE` | Runtime mode. |
12| `--port <number>` | `T3CODE_PORT` | HTTP/WebSocket port. |
13| `--host <address>` | `T3CODE_HOST` | Bind interface/address. |
14| `--base-dir <path>` | `T3CODE_HOME` | Base directory. |
15| `--dev-url <url>` | `VITE_DEV_SERVER_URL` | Dev web URL redirect/proxy target. |
16| `--no-browser` | `T3CODE_NO_BROWSER` | Disable auto-open browser. |
17| `--auth-token <token>` | `T3CODE_AUTH_TOKEN` | WebSocket auth token. Use this for standard CLI and remote-server flows. |
18| `--bootstrap-fd <fd>` | `T3CODE_BOOTSTRAP_FD` | Read a one-shot bootstrap envelope from an inherited file descriptor during startup. |
19​
20> TIP: Use the `--help` flag to see all available options and their descriptions.
21​
22## Security First
23​
24- Always set `--auth-token` before exposing the server outside localhost.
25 - When you control the process launcher, prefer sending the auth token in a JSON envelope via `--bootstrap-fd <fd>`.
26 With `--bootstrap-fd <fd>`, the launcher starts the server first, then sends a one-shot JSON envelope over the inherited file descriptor. This allows the auth token to be delivered without putting it in process environment or command line arguments.
27- Treat the token like a password.
28- Prefer binding to trusted interfaces (LAN IP or Tailnet IP) instead of opening all interfaces unless needed.
29​
30## 1) Build + run server for remote access
31​
32Remote access should use the built web app (not local Vite redirect mode).
33​
34```bash
35bun run build
36TOKEN="$(openssl rand -hex 24)"
37bun run --cwd apps/server start -- --host 0.0.0.0 --port 3773 --auth-token "$TOKEN" --no-browser
38```
39​
40Then open on your phone:
41​
42`http://<your-machine-ip>:3773`
43​
44Example:
45​
46`http://192.168.1.42:3773`
47​
48Notes:
49​
50- `--host 0.0.0.0` listens on all IPv4 interfaces.
51- `--no-browser` prevents local auto-open, which is usually better for headless/remote sessions.
52- Ensure your OS firewall allows inbound TCP on the selected port.
53​
54## 2) Tailnet / Tailscale access
55​
56If you use Tailscale, you can bind directly to your Tailnet address.
57​
58```bash
59TAILNET_IP="$(tailscale ip -4)"
60TOKEN="$(openssl rand -hex 24)"
61bun run --cwd apps/server start -- --host "$(tailscale ip -4)" --port 3773 --auth-token "$TOKEN" --no-browser
62```
63​
64Open from any device in your tailnet:
65​
66`http://<tailnet-ip>:3773`
67​
68You can also bind `--host 0.0.0.0` and connect through the Tailnet IP, but binding directly to the Tailnet IP limits exposure.