로컬 환경 분리와 회원가입 중복 검증 보강

로컬 개발 환경은 .env.local을 우선 읽고 운영은 .env.production만 읽도록 분리해 인증 우회 설정이 운영에 섞이지 않게 정리했다. 회원가입/로그인 이메일 정규화와 중복 예외 처리를 보강해 대소문자·공백 변형 중복 가입을 안정적으로 차단했다.

Made-with: Cursor
This commit is contained in:
2026-04-27 11:33:10 +09:00
committed by DUCK JIN
parent 069eda3544
commit 73d198f5a9
12 changed files with 105 additions and 25 deletions

View File

@@ -6,7 +6,22 @@ const cors = require('cors')
const session = require('express-session')
const FileStoreFactory = require('session-file-store')
dotenv.config({ path: path.join(__dirname, '..', '.env.production') })
function loadEnvFileIfExists(fileName) {
const envPath = path.join(__dirname, '..', fileName)
if (!fs.existsSync(envPath)) return false
dotenv.config({ path: envPath })
return true
}
loadEnvFileIfExists('.env')
const nodeEnv = String(process.env.NODE_ENV || 'development').trim().toLowerCase()
if (nodeEnv === 'production') {
loadEnvFileIfExists('.env.production')
} else {
const loadedLocal = loadEnvFileIfExists('.env.local')
if (!loadedLocal) loadEnvFileIfExists('.env.production')
}
const { ensureData } = require('./src/db')
const authRoutes = require('./src/routes/auth')