Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Copilot stopped work on behalf of
redsunjin due to an error
March 6, 2026 15:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
api/chat.js- Gemini API serverless function with retry logic, CORS, system instructionapi/send-email.js- EmailJS serverless function with honeypot validation, CORSindex.html- Remove all API keys, implement 4-step state machine (inquiry → privacy → contact → send), add rate limiting, honeypot, XSS protectionOriginal prompt
목표
기존
index.html의 Gemini 챗봇을 Vercel 서버리스 함수 구조로 전환하여 API 키를 브라우저에 노출하지 않고 환경변수로 안전하게 관리한다.배포 도메인:
https://flashgta-github-io.vercel.app파일 구조
1.
api/chat.js— Gemini API 서버리스 함수Vercel Serverless Function으로 작성한다.
기능
POST /api/chat요청을 받아 Gemini API를 호출하고 응답 반환GEMINI_API_KEY사용 (process.env.GEMINI_API_KEY)contents배열(대화 히스토리) 전체를 request body로 받아 Gemini에 전달Access-Control-Allow-Origin: https://flashgta-github-io.vercel.appsystemInstruction (기존 유지 + [INQUIRY_COMPLETE] 태그 추가)
Request Body
{ "contents": [ {"role": "user", "parts": [{"text": "..."}]}, {"role": "model", "parts": [{"text": "..."}]} ] }Response
{ "text": "AI 응답 텍스트" }Gemini 모델
gemini-2.0-flash사용2.
api/send-email.js— 이메일 발송 서버리스 함수기능
POST /api/send-email요청을 받아 EmailJS REST API를 호출하여 이메일 발송EMAILJS_PUBLIC_KEYEMAILJS_PRIVATE_KEY(EmailJS REST API 호출 시 필요)EMAILJS_SERVICE_IDEMAILJS_TEMPLATE_IDAccess-Control-Allow-Origin: https://flashgta-github-io.vercel.apphoneypot필드가 있으면 400 반환EmailJS REST API 호출
Request Body
{ "visitor_name": "홍길동", "contact": "hong@example.com", "inquiry_summary": "재난지원금 신청 앱 개발 문의", "full_conversation": "전체 대화 텍스트", "date": "2026-03-06 15:30", "honeypot": "" }3.
index.html수정핵심 변경사항
/api/chat호출로 변경/api/send-email호출로 변경단계별 상담 흐름 (State Machine)
챗봇이 다음 4단계를 순서대로 진행:
STEP 1
inquiry:/api/chat호출로 Gemini와 멀티턴 대화[INQUIRY_COMPLETE]태그가 포함되면 자동으로 STEP 2로 전환STEP 2
privacy: 개인정보 수집 동의 안내 (Gemini API 호출 없음, 챗봇 자체 로직)STEP 3
contact: 이름과 연락처(이메일 또는 전화번호) 수집 (Gemini API 호출 없음)STEP 4
send:/api/send-email호출 (Gemini API 호출 없음)봇 방지 (프론트엔드)
display:none숨겨진 input 추가, 값이 있으면 전송 차단초기 메시지
Gemini 재시도 로직 (프론트엔드
/api/chat호출 시)4. 환경변수 설정 안내 (README 또는 주석)
Vercel 대시보드에서 아래 환경변수를 설정해야 한다:
api/chat.js와api/send-email.js상단 주석에 위 안내를 포함한다.주의사항
index.html에서 API 키 관련 코드 완전히 제거.ai-fab,.ai-chat-window, 애니메이션 등) 완전 유지style.css는 수...This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.