diff --git a/.env.development b/.env.development new file mode 100644 index 00000000..68407dbb --- /dev/null +++ b/.env.development @@ -0,0 +1,3 @@ +# 개발 서버 (배포된 개발 환경) +VITE_API_URL=https://dev-api.ttorang.com +VITE_APP_TITLE=또랑 (개발) diff --git a/.env.example b/.env.example index 22c43d51..9d17a9c6 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,20 @@ +# =========================================== +# 환경변수 템플릿 +# 이 파일을 복사해서 .env.local 파일을 만드세요 +# =========================================== -# API +# API 서버 URL +# - 개발: https://dev-api.ttorang.com +# - 프로덕션: https://api.ttorang.com VITE_API_URL= -# App +# 앱 타이틀 VITE_APP_TITLE=또랑 + +# =========================================== +# 시크릿 키 (반드시 .env.local에만 설정하세요) +# =========================================== + +# 카카오 JavaScript 키 (공유 기능용) +# https://developers.kakao.com 에서 발급 +VITE_KAKAO_JS_KEY= diff --git a/.env.production b/.env.production new file mode 100644 index 00000000..488bfc41 --- /dev/null +++ b/.env.production @@ -0,0 +1,3 @@ +# 프로덕션 서버 +VITE_API_URL=https://api.ttorang.com +VITE_APP_TITLE=또랑 diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index a7b71f91..0f88e3cb 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -1,18 +1,33 @@ -# This file was auto-generated by the Firebase CLI -# https://github.com/firebase/firebase-tools - name: Deploy to Firebase Hosting on merge + on: push: branches: - main + jobs: build_and_deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: npm ci && npm run build - - uses: FirebaseExtended/action-hosting-deploy@v0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + env: + VITE_API_URL: ${{ secrets.VITE_API_URL }} + VITE_KAKAO_JS_KEY: ${{ secrets.VITE_KAKAO_JS_KEY }} + + - name: Deploy to Firebase + uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_TTORANG }} diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml index 2df385a0..b2aac072 100644 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -1,20 +1,36 @@ -# This file was auto-generated by the Firebase CLI -# https://github.com/firebase/firebase-tools - name: Deploy to Firebase Hosting on PR + on: pull_request + permissions: checks: write contents: read pull-requests: write + jobs: build_and_preview: if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: npm ci && npm run build - - uses: FirebaseExtended/action-hosting-deploy@v0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + env: + VITE_API_URL: ${{ secrets.VITE_API_URL }} + VITE_KAKAO_JS_KEY: ${{ secrets.VITE_KAKAO_JS_KEY }} + + - name: Deploy Preview to Firebase + uses: FirebaseExtended/action-hosting-deploy@v0 with: repoToken: ${{ secrets.GITHUB_TOKEN }} firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_TTORANG }} diff --git a/firebase.json b/firebase.json index 2c33c295..fdd45898 100644 --- a/firebase.json +++ b/firebase.json @@ -1,16 +1,53 @@ { "hosting": { "public": "dist", - "ignore": [ - "firebase.json", - "**/.*", - "**/node_modules/**" - ], + "ignore": ["firebase.json", "**/.*", "**/node_modules/**"], "rewrites": [ { "source": "**", "destination": "/index.html" } + ], + "headers": [ + { + "source": "**/*.@(js|css|jpg|jpeg|png|gif|webp|svg|ico|woff|woff2)", + "headers": [ + { + "key": "Cache-Control", + "value": "public, max-age=31536000, immutable" + } + ] + }, + { + "source": "index.html", + "headers": [ + { + "key": "Cache-Control", + "value": "no-cache, no-store, must-revalidate" + } + ] + }, + { + "source": "**", + "headers": [ + { + "key": "Content-Security-Policy", + "value": "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; connect-src 'self' https://dev-api.ttorang.com https://api.ttorang.com https://developers.kakao.com; frame-ancestors 'none'" + }, + { + "key": "X-Frame-Options", + "value": "DENY" + }, + { + "key": "X-Content-Type-Options", + "value": "nosniff" + }, + { + "key": "Referrer-Policy", + "value": "strict-origin-when-cross-origin" + } + ] + } ] } }