fix: 외주 플랫폼 전환율 개선 + API 보안 정비 + 시크릿 노출 제거

[Backend API]
- contact/route: 문의 내역 contact_requests DB 저장 추가 (이메일+DB 병행)
- projects/route, link/route: 미사용 Bearer 토큰 인증 제거, Cookie 전용
- projects/route: DB 에러 메시지 클라이언트 노출 차단 (console.error로 전환)
- quote/[token]/route: valid_until 만료 검증 + expired 플래그 응답 추가

[Frontend UX]
- mypage: 로또 잔존 코드 완전 제거 (PLAN_LABELS, lotto_history 쿼리)
- mypage: 기본 탭 projects로 변경, 탭 순서 외주 고객 우선 재배치
- freelance: 포트폴리오 가격대 뱃지 추가, 각 항목 CTA 링크 추가
- freelance: 후기 섹션 하단 CTA 블록 추가

[견적서 페이지]
- quote/[token]/page: 만료 견적서 경고 배너 + 수락 버튼 숨김
- quote/layout: DashboardShell 없이 독립 렌더링

[보안]
- test-flow.mjs: 하드코딩 시크릿 → .env.test 환경변수 참조로 교체
- GitGuardian 3건 대응 (admin password, JWT, test password)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-02 08:49:05 +09:00
parent 2c9af41631
commit fe1e8ffcf0
9 changed files with 152 additions and 111 deletions

View File

@@ -8,6 +8,8 @@ import {
getClientIp,
INPUT_LIMITS,
} from '@/lib/security';
import { createAdminClient } from '@/lib/supabase/admin';
import { createClient } from '@/lib/supabase/server';
const resend = new Resend(process.env.RESEND_API_KEY);
@@ -58,27 +60,67 @@ export async function POST(request: Request) {
// message는 pre-wrap으로 렌더링되므로 반드시 이스케이프
const safeMessage = escapeHtml(message);
await resend.emails.send({
from: 'onboarding@resend.dev',
to: ['bgg8988@gmail.com'],
replyTo: email,
subject: `[쟁승메이드] 새로운 문의: ${safeSubject}`,
html: `
<h2>새로운 프로젝트 문의가 도착했습니다</h2>
<hr />
<p><strong>이름:</strong> ${safeName}</p>
<p><strong>연락처:</strong> ${safePhone}</p>
<p><strong>이메일:</strong> ${safeEmail}</p>
<p><strong>서비스:</strong> ${safeService}</p>
<hr />
<h3>문의 내용:</h3>
<p style="white-space: pre-wrap;">${safeMessage}</p>
<hr />
<p style="color: #666; font-size: 12px;">
이 메일은 jaengseung-made.com의 문의 폼에서 발송되었습니다.
</p>
`,
});
// ── 로그인 사용자 확인 (optional) ─────────────────────────
let userId: string | null = null;
try {
const supabase = await createClient();
const { data } = await supabase.auth.getUser();
userId = data?.user?.id ?? null;
} catch {
// 비로그인 상태 — 무시
}
// ── 이메일 전송 ──────────────────────────────────────────
let emailSent = true;
try {
await resend.emails.send({
from: 'onboarding@resend.dev',
to: ['bgg8988@gmail.com'],
replyTo: email,
subject: `[쟁승메이드] 새로운 문의: ${safeSubject}`,
html: `
<h2>새로운 프로젝트 문의가 도착했습니다</h2>
<hr />
<p><strong>이름:</strong> ${safeName}</p>
<p><strong>연락처:</strong> ${safePhone}</p>
<p><strong>이메일:</strong> ${safeEmail}</p>
<p><strong>서비스:</strong> ${safeService}</p>
<hr />
<h3>문의 내용:</h3>
<p style="white-space: pre-wrap;">${safeMessage}</p>
<hr />
<p style="color: #666; font-size: 12px;">
이 메일은 jaengseung-made.com의 문의 폼에서 발송되었습니다.
</p>
`,
});
} catch (emailError) {
console.error('[Contact] Email send error:', emailError);
emailSent = false;
}
// ── DB 저장 (이메일 성공/실패 무관) ──────────────────────
try {
const admin = createAdminClient();
await admin.from('contact_requests').insert({
name,
email,
phone: phone || null,
service: service || null,
message,
user_id: userId,
created_at: new Date().toISOString(),
});
} catch (dbError) {
console.error('[Contact] DB insert error:', dbError);
}
if (!emailSent) {
return NextResponse.json(
{ error: '메일 전송에 실패했습니다. 다시 시도해주세요.' },
{ status: 500 }
);
}
return NextResponse.json(
{ success: true, message: '문의가 성공적으로 전송되었습니다!' },
@@ -86,9 +128,9 @@ export async function POST(request: Request) {
);
} catch (error) {
// 클라이언트에 내부 오류 상세 노출 금지
console.error('[Contact] Email send error:', error);
console.error('[Contact] Unexpected error:', error);
return NextResponse.json(
{ error: '메일 전송에 실패했습니다. 다시 시도해주세요.' },
{ error: '문의 처리 중 오류가 발생했습니다. 다시 시도해주세요.' },
{ status: 500 }
);
}