본문으로 건너뛰기

환경 변수

모든 ChurchApps 프로젝트는 로컬 구성을 위해 .env 파일을 사용합니다. 각 프로젝트는 복사하고 사용자 정의할 샘플 파일을 포함합니다. 이 페이지는 스테이징과 로컬 API 대상 선택 방법을 포함하여 API, 웹 앱, 모바일 앱의 환경 변수를 다룹니다.

시작하기 전에

일반 패턴

  1. 프로젝트 루트에서 dotenv.sample.txt 또는 .env.sample을 찾으세요.
  2. .env로 복사하세요.
  3. 필요에 따라 값을 수정하세요.
# .env.sample을 가진 프로젝트의 예
cp .env.sample .env

# dotenv.sample.txt를 가진 프로젝트의 예
cp dotenv.sample.txt .env
경고

.env 파일을 버전 관리에 커밋하지 마세요. 이들은 데이터베이스 자격증명, API 키, JWT 보안 같은 보안을 포함합니다. 모든 ChurchApps 프로젝트는 .gitignore.env를 포함하지만, 커밋하기 전에 항상 다시 확인하세요.

API 대상 선택

가장 중요한 결정은 프론트엔드가 API 호출을 위해 어디를 가리키는지입니다. 두 가지 옵션이 있습니다:

옵션 1: 스테이징 API (프론트엔드 개발에 권장)

공유 스테이징 환경을 사용하세요. 로컬 API 또는 데이터베이스 설정이 필요하지 않습니다.

# 기본 URL 패턴
https://api.staging.churchapps.org/{module}

# 예시 모듈 URL
https://api.staging.churchapps.org/membership
https://api.staging.churchapps.org/attendance
https://api.staging.churchapps.org/content
https://api.staging.churchapps.org/giving
https://api.staging.churchapps.org/messaging
https://api.staging.churchapps.org/doing

옵션 2: 로컬 API

머신에서 Api 프로젝트를 실행하세요. 각 모듈에 대해 생성된 MySQL 8.0+ 데이터베이스가 필요합니다. API 로컬 설정 가이드를 참조하세요.

# 기본 URL 패턴
http://localhost:8084/{module}

# 예시 모듈 URL
http://localhost:8084/membership
http://localhost:8084/attendance
http://localhost:8084/content
http://localhost:8084/giving
http://localhost:8084/messaging
http://localhost:8084/doing

API 환경 변수

핵심 Api 프로젝트 (.env.sample)에는 가장 많은 구성이 있습니다. 주요 변수:

공유 설정

변수설명
ENVIRONMENT런타임 환경dev
SERVER_PORT로컬 개발 서버의 HTTP 포트8084
ENCRYPTION_KEY민감한 데이터를 위한 192비트 암호화 키aSecretKeyOfExactly192BitsLength
JWT_SECRETJSON 웹 토큰 서명 보안jwt-secret-dev
FILE_STORE업로드된 파일 저장 위치 (disk 또는 s3)disk
CORS_ORIGIN허용된 CORS 출처 (로컬 개발은 *)*

데이터베이스 연결

각 API 모듈은 자신의 MySQL 데이터베이스 및 연결 문자열을 가집니다:

변수데이터베이스
MEMBERSHIP_CONNECTION_STRINGmysql://root:password@localhost:3306/membership
ATTENDANCE_CONNECTION_STRINGmysql://root:password@localhost:3306/attendance
CONTENT_CONNECTION_STRINGmysql://root:password@localhost:3306/content
GIVING_CONNECTION_STRINGmysql://root:password@localhost:3306/giving
MESSAGING_CONNECTION_STRINGmysql://root:password@localhost:3306/messaging
DOING_CONNECTION_STRINGmysql://root:password@localhost:3306/doing

root:password를 실제 MySQL 자격증명으로 업데이트하세요. 각 데이터베이스는 API를 실행하기 전에 생성되어야 합니다. 모든 모듈의 스키마를 생성하려면 npm run initdb를 사용하거나, 단일 모듈의 경우 npm run initdb:membership을 사용하세요.

WebSocket 설정

변수설명
SOCKET_PORTWebSocket 서버의 포트8087
SOCKET_URL클라이언트가 연결할 WebSocket URLws://localhost:8087

웹 앱 환경 변수

B1Admin (React + Vite)

샘플 파일: .env.sample

변수설명예 (스테이징)
REACT_APP_STAGE환경 이름demo
PORT개발 서버 포트3101
REACT_APP_MEMBERSHIP_API회원 API URLhttps://api.staging.churchapps.org/membership
REACT_APP_ATTENDANCE_API참석 API URLhttps://api.staging.churchapps.org/attendance
REACT_APP_GIVING_API헌금 API URLhttps://api.staging.churchapps.org/giving
REACT_APP_CONTENT_ROOT컨텐츠 배달 URLhttps://content.staging.churchapps.org
REACT_APP_GOOGLE_ANALYTICSGoogle 분석 ID (선택)UA-123456789-1

로컬 API 개발의 경우 localhost 변형을 주석 해제하고 사용:

REACT_APP_MEMBERSHIP_API=http://localhost:8084/membership
REACT_APP_ATTENDANCE_API=http://localhost:8084/attendance
REACT_APP_GIVING_API=http://localhost:8084/giving
REACT_APP_CONTENT_API=http://localhost:8084/content
REACT_APP_DOING_API=http://localhost:8084/doing
REACT_APP_MESSAGING_API=http://localhost:8084/messaging

B1App (Next.js)

샘플 파일: .env.sample

변수설명예 (스테이징)
NEXT_PUBLIC_MEMBERSHIP_API회원 API URLhttps://api.staging.churchapps.org/membership
NEXT_PUBLIC_ATTENDANCE_API참석 API URLhttps://api.staging.churchapps.org/attendance
NEXT_PUBLIC_GIVING_API헌금 API URLhttps://api.staging.churchapps.org/giving
NEXT_PUBLIC_MESSAGING_API메시징 API URLhttps://api.staging.churchapps.org/messaging
NEXT_PUBLIC_CONTENT_API컨텐츠 API URLhttps://api.staging.churchapps.org/content
NEXT_PUBLIC_CONTENT_ROOT컨텐츠 배달 URLhttps://staging.churchapps.org/content
NEXT_PUBLIC_CHURCH_APPS_URLChurchApps 기본 URLhttps://staging.churchapps.org
NEXT_PUBLIC_GOOGLE_ANALYTICSGoogle 분석 ID (선택)UA-123456789-1
정보

Next.js는 브라우저에서 사용 가능해야 하는 모든 환경 변수에 NEXT_PUBLIC_ 접두사를 요구합니다. 서버만 변수는 이 접두사가 필요하지 않습니다.

LessonsApp (Next.js)

샘플 파일: dotenv.sample.txt

변수설명예 (스테이징)
STAGE환경 스테이지staging
NEXT_PUBLIC_LESSONS_APILessons API URLhttps://api.staging.lessons.church
NEXT_PUBLIC_CONTENT_ROOT컨텐츠 배달 URLhttps://api.staging.lessons.church/content
NEXT_PUBLIC_CHURCH_APPS_URLChurchApps 기본 URLhttps://staging.churchapps.org

모바일 앱 환경 변수

B1Mobile (React Native / Expo)

샘플 파일: dotenv.sample.txt

변수설명예 (스테이징)
STAGE환경 이름dev
MEMBERSHIP_API회원 API URLhttps://api.staging.churchapps.org/membership
MESSAGING_API메시징 API URLhttps://api.staging.churchapps.org/messaging
ATTENDANCE_API참석 API URLhttps://api.staging.churchapps.org/attendance
GIVING_API헌금 API URLhttps://api.staging.churchapps.org/giving
DOING_API할 일 API URLhttps://api.staging.churchapps.org/doing
CONTENT_API컨텐츠 API URLhttps://api.churchapps.org/content
CONTENT_ROOT컨텐츠 배달 URLhttps://content.staging.churchapps.org
LESSONS_ROOTLessons 사이트 URLhttps://staging.lessons.church
정보

모바일 앱은 REACT_APP_ 또는 NEXT_PUBLIC_ 접두사를 사용하지 않습니다. 환경 변수 액세스는 Expo 구성에서 처리됩니다.


빠른 참조: 샘플 파일 위치

프로젝트샘플 파일
Api.env.sample
B1Admin.env.sample
B1App.env.sample
B1Mobiledotenv.sample.txt
B1Checkindotenv.sample.txt
LessonsAppdotenv.sample.txt
AskApidotenv.sample.txt