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

+2 -7
View File
@@ -8,7 +8,7 @@
import { useEffect, useRef, useState } from 'react';
import { useParams, Link } from 'react-router';
import { motion } from 'motion/react';
import { supabase } from '../lib/supabase';
import { db } from '../lib/db';
import { BUILD_STEPS, STATE_LABEL, progressOf, stepStates, warningsOf } from '../lib/buildPhases';
import type { BuildState, PhaseRow } from '../lib/buildPhases';
import { CheckFilled, WarningFilled, EyeFilled, PrismFilled } from '../components/icons/FilledIcons';
@@ -40,12 +40,7 @@ export default function SiteBuildPage() {
let alive = true;
async function tick() {
const { data, error } = await supabase
.from('supporter_builds')
.select('id,clinic_id,clinic_name,status,phase,phases,posts,preview_url,error,updated_at')
.eq('clinic_id', id)
.order('created_at', { ascending: false })
.limit(1);
const { data, error } = await db<Build[]>('builds.latest', { clinicId: id, fields: 'site' });
if (!alive) return;
if (error) setLoadError(error.message);
const row = (data?.[0] as Build) ?? null;