From a60c3c98965a698ee2467373f772c48abaa217ce Mon Sep 17 00:00:00 2001 From: zenn Date: Fri, 3 Apr 2026 11:44:35 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A6=B4=EB=A6=AC=EC=8A=A4:=20v1.4.47=20?= =?UTF-8?q?=EB=A1=9C=EC=BB=AC=20SMTP=20=ED=99=98=EA=B2=BD=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EB=A1=9C=EB=93=9C=20=EB=B3=B4=EA=B0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/index.js | 3 +++ backend/package-lock.json | 13 +++++++++++++ backend/package.json | 1 + docs/todo.md | 1 + docs/update.md | 4 ++++ 5 files changed, 22 insertions(+) diff --git a/backend/index.js b/backend/index.js index 208cc99..1825f04 100644 --- a/backend/index.js +++ b/backend/index.js @@ -1,10 +1,13 @@ const path = require('path') const fs = require('fs') +const dotenv = require('dotenv') const express = require('express') const cors = require('cors') const session = require('express-session') const FileStoreFactory = require('session-file-store') +dotenv.config({ path: path.join(__dirname, '..', '.env.production') }) + const { ensureData } = require('./src/db') const authRoutes = require('./src/routes/auth') const topicsRoutes = require('./src/routes/topics') diff --git a/backend/package-lock.json b/backend/package-lock.json index 6017748..85df282 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "bcryptjs": "^3.0.3", "cors": "^2.8.6", + "dotenv": "^17.4.0", "express": "^5.2.1", "express-session": "^1.19.0", "multer": "^2.1.1", @@ -854,6 +855,18 @@ "node": ">=8" } }, + "node_modules/dotenv": { + "version": "17.4.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.0.tgz", + "integrity": "sha512-kCKF62fwtzwYm0IGBNjRUjtJgMfGapII+FslMHIjMR5KTnwEmBmWLDRSnc3XSNP8bNy34tekgQyDT0hr7pERRQ==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", diff --git a/backend/package.json b/backend/package.json index 85eb687..4244b5e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -17,6 +17,7 @@ "dependencies": { "bcryptjs": "^3.0.3", "cors": "^2.8.6", + "dotenv": "^17.4.0", "express": "^5.2.1", "express-session": "^1.19.0", "multer": "^2.1.1", diff --git a/docs/todo.md b/docs/todo.md index 543ee29..f511487 100644 --- a/docs/todo.md +++ b/docs/todo.md @@ -1,6 +1,7 @@ # 할 일 및 이슈 ## 단기 확인 +- `v1.4.47`에서 로컬 백엔드가 루트 `.env.production`을 읽도록 바꿨으므로, `SMTP_PASS` 교체 후 백엔드를 다시 띄우고 로컬 회원가입이 더 이상 `mail_not_configured` 503으로 떨어지지 않는지 확인한다. - `.env.production`의 `SMTP_PASS=여기에_Gmail_앱_비밀번호_입력` placeholder를 실제 Gmail 앱 비밀번호로 교체한 뒤, 운영 컨테이너를 재기동해서 회원가입 인증 메일과 비밀번호 재설정 메일이 실제로 발송되는지 확인한다. - `v1.4.45`에서 이메일 인증/비밀번호 재설정 메일 발송을 Gmail SMTP로 붙였으므로, 운영 `.env`에 `SMTP_USER`, `SMTP_PASS`, `SMTP_HOST`, `SMTP_PORT`, `SMTP_SECURE`, `SMTP_FROM`, `APP_ORIGIN`을 넣은 뒤 실제 회원가입 인증 메일과 비밀번호 재설정 메일이 도착하는지 확인한다. - 일반 회원가입 직후에는 자동 로그인되지 않고 인증 안내 문구가 떠야 하며, 메일의 `login?verifyToken=...` 링크를 누르면 이메일 인증과 로그인 세션 생성이 함께 끝나는지 QA한다. diff --git a/docs/update.md b/docs/update.md index 092e4ed..c15edb0 100644 --- a/docs/update.md +++ b/docs/update.md @@ -1,5 +1,9 @@ # 업데이트 로그 +## 2026-04-03 v1.4.47 +- 로컬 개발 서버를 `npm run dev:backend`로 띄울 때 루트 `.env.production`의 `SMTP_*` 값이 자동으로 들어가지 않아 일반 회원가입이 `mail_not_configured` 503으로 실패할 수 있었으므로, 백엔드 엔트리에서 `dotenv`로 루트 `.env.production`을 먼저 로드하도록 보강했다. +- 이 변경으로 Docker Compose 운영 환경은 기존 컨테이너 환경변수를 그대로 쓰면서, 로컬 개발 서버도 같은 `.env.production`의 Gmail SMTP 설정을 읽어 이메일 인증/비밀번호 재설정 메일 발송을 테스트할 수 있게 됐다. + ## 2026-04-03 v1.4.46 - 운영용 `.env.production`에는 Git에 올리지 않는 로컬 비밀값을 유지한 채, Gmail SMTP 발송에 필요한 `APP_ORIGIN`, `SMTP_HOST`, `SMTP_PORT`, `SMTP_SECURE`, `SMTP_USER`, `SMTP_PASS`, `SMTP_FROM` 항목을 추가했다. - Git에 추적되는 `.env.production.example`에도 같은 SMTP 환경변수 예시를 추가해, 실제 배포 설정에서 어떤 키를 채워야 하는지 파일만 보고도 바로 알 수 있게 정리했다.