fix: 데모 화면의 DB 조회·쓰기를 서버 함수로 옮긴다

브라우저가 공개 키로 테이블을 직접 읽고 쓰던 구조를 없앤다.
- api/db.js: 정해진 작업만 서비스 키로 실행 (임의 쿼리·열 지정 불가)
- api/_origin.js: 서버 함수 공용 출처 검사, 공개 배포에서는 404
- src/lib/db.ts: 화면용 호출 함수, 반환 형태 { data, error } 유지
- 빌드 큐에 바로 넣던 예전 진단 신청 모달 삭제

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Opus 5.5 committed 2026-10-07 16:09:29 +09:00
1 parent b91fdf1a6a
commit 0be730f0f9
14 files changed
+264 -378

No files matched your search

@@ -7,7 +7,7 @@
*/
import { useEffect, useMemo, useState } from 'react';
import { motion, AnimatePresence } from 'motion/react';
import { supabase } from '../../lib/supabase';
import { db } from '../../lib/db';
import { CheckFilled, CrossFilled, EyeFilled, WarningFilled, LinkExternalFilled } from '../icons/FilledIcons';
type Role = 'hero' | 'used' | 'stored';
@@ -67,8 +67,8 @@ export function ImageReviewPanel({ clinicId }: { clinicId: string }) {
let alive = true;
void (async () => {
const [b, inputs] = await Promise.all([
supabase.from('supporter_builds').select('id,status,preview_url,report,updated_at').eq('clinic_id', clinicId).order('created_at', { ascending: false }).limit(1),
supabase.from('supporter_inputs').select('value,input_by,created_at').eq('clinic_id', clinicId).eq('key', 'image_review').order('created_at', { ascending: true }),
db<Build[]>('builds.latest', { clinicId, fields: 'image' }),
db<Array<{ value: Record<string, unknown>; input_by: string | null; created_at: string }>>('inputs.list', { clinicId, key: 'image_review' }),
]);
if (!alive) return;
if (b.error) setLoadError(b.error.message);
@@ -103,11 +103,11 @@ export function ImageReviewPanel({ clinicId }: { clinicId: string }) {
async function save() {
setSaving(true);
setSaveError(null);
const { error } = await supabase.from('supporter_inputs').insert({
clinic_id: clinicId,
const { error } = await db('inputs.add', {
clinicId,
key: 'image_review',
value: { decisions, excludeImages: excluded.map((i) => i.id), total: items.length, decidedAt: new Date().toISOString() },
input_by: inputBy.trim() || null,
inputBy: inputBy.trim() || null,
});
setSaving(false);
if (error) { setSaveError(error.message); return; }