Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# 웹뷰로 띄울 stream-client-web 주소.
# 이 파일을 .env.local로 복사한 뒤 값을 자기 환경에 맞게 채운다.
#
# 실행 환경마다 주소가 다르다 (docs/local-development.md 참고):
# 웹을 직접 띄우지 않고 배포된 dev 환경을 볼 거라면 아래 주소를 그대로 쓰면 된다.
# https://dev.stream.billilge.site
#
# 웹을 로컬에서 띄운다면 실행 환경마다 주소가 다르다 (docs/local-development.md 참고):
# - iOS 시뮬레이터 http://localhost:5173
# - Android 에뮬레이터 http://10.0.2.2:5173
# - 실제 기기 http://{개발 PC의 LAN IP}:5173
#
# LAN IP 확인: ipconfig getifaddr en0
# 실제 기기는 PC와 같은 네트워크에 있어야 하고, 웹도 pnpm dev --host로 띄워야 한다.
# 배포 후에는 운영 URL로 바꾼다.
EXPO_PUBLIC_WEB_URL=http://192.168.0.2:5173
#
# 배포 빌드(eas build)는 이 파일을 쓰지 않는다 — eas.json의 프로필별 env로 주입된다.
EXPO_PUBLIC_WEB_URL=http://localhost:5173
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,26 @@ WebView가 띄울 주소는 `.env.local`의 `EXPO_PUBLIC_WEB_URL`로 주입한

실제 기기에서는 `localhost`가 기기 자신을 가리켜 개발 PC에 닿지 않으므로 LAN IP를 써야 하고, 웹도 `pnpm dev --host`로 띄워야 한다.

웹을 직접 띄우지 않고 앱만 볼 거라면 배포된 dev 환경을 가리켜도 된다 — `https://dev.stream.billilge.site`

자세한 실행 방법·준비물·트러블슈팅은 **[docs/local-development.md](docs/local-development.md)** 참고.

### 배포 빌드의 웹 주소

`.env.local`은 로컬 실행 전용이다. `EXPO_PUBLIC_*`는 런타임이 아니라 **빌드 시점에 번들에 문자열로 박히고**, `.env.local`은 git에 올라가지 않아 EAS 클라우드 빌드에는 존재하지 않는다. 그래서 배포 빌드의 주소는 `eas.json`의 프로필별 `env`로 주입한다.

| 프로필 | `EXPO_PUBLIC_WEB_URL` |
| --- | --- |
| `development` | 주입하지 않음 — 로컬 metro가 `.env.local`을 읽는다 |
| `preview` | `https://dev.stream.billilge.site` |
| `production` | **아직 비어 있음** — 운영 주소가 정해지면 채운다 |

`production`을 비워 둔 값으로 빌드하면 앱이 "웹 주소가 설정되지 않았습니다" 안내 화면을 띄운다. 잘못된 주소로 조용히 배포되는 것보다 낫다고 보고 일부러 채우지 않았다.

번들에 그대로 박히므로 **비밀값은 `EXPO_PUBLIC_*`에 넣지 않는다.** 웹 주소는 공개돼도 되는 값이라 `eas.json`에 평문으로 둔다.

`eas build`를 실제로 돌리려면 `eas init`으로 `app.json`에 `extra.eas.projectId`가 먼저 채워져야 한다.

## 스크립트

| 명령 | 설명 |
Expand Down
4 changes: 4 additions & 0 deletions docs/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ cp .env.example .env.local
| Android 에뮬레이터 | `http://10.0.2.2:5173` | `10.0.2.2`가 호스트 PC의 `localhost`에 매핑된다 |
| 실제 기기 (Expo Go) | `http://{개발 PC의 LAN IP}:5173` | 기기와 PC가 같은 네트워크에 있어야 한다 |

웹까지 직접 띄우기 번거로우면 배포된 dev 환경(`https://dev.stream.billilge.site`)을 가리켜도 된다. 이 경우 아래 "2. 웹 서버 띄우기"는 건너뛴다. 다만 웹을 고치면서 보려면 로컬 주소를 써야 한다.

배포 빌드(`eas build`)는 `.env.local`이 아니라 `eas.json`의 프로필별 `env`로 주소를 주입한다 — [README](../README.md#배포-빌드의-웹-주소) 참고.

LAN IP 확인:

```bash
Expand Down
23 changes: 23 additions & 0 deletions eas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"cli": {
"appVersionSource": "remote"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal",
"env": {
"EXPO_PUBLIC_WEB_URL": "https://dev.stream.billilge.site"
}
},
"production": {
"autoIncrement": true
}
},
"submit": {
"production": {}
}
}
Loading