AI

사주 AI 웹서비스 제작노트 - 4

찐망고 2026. 4. 2. 14:36
반응형

 

 

사주 AI 웹서비스 제작노트 -3

사주 AI 웹서비스 제작노트 -2사주 AI 웹서비스 제작노트 - 1사주 AI 웹서비스를 첫 API 프로젝트로 시작한 이유첫 AI웹서비스를 사주로 선택한건 사주 자체에 관심이 많아서도 맞는데 포스텔러나,

uiweb.tistory.com

 

바로 배포하려고 3월말로 잡았는데

4월이 되었다 하하하

일단 테스트 기간이 좀 더 길어졌다는 점 

fs기반의 로컬 캐시 방식은 나중에 Vercel같은 클라우드 서버에 올리면 작동하지 않을터

회원가입을 당장 하진 않더라도 사주명식 자체가 고유한 키가 되기때문에

DB를 연결하는 것이 서비스의 신뢰도와 API비용절감을 위해도 좋을거라 생각했다.

 

무료티어가 가장 넉넉한 Supabase(PostgreSQL)을 기준으로 설계하기로 함

깃허브로 로그인하는데 문제 생김

 

Supabase | The Postgres Development Platform.

Build production-grade applications with a Postgres database, Authentication, instant APIs, Realtime, Functions, Storage and Vector embeddings. Start for free.

supabase.com

 

새프로젝트를 눌러 깃허브로 로그인하자마자 에러 뜸

"This account is flagged..." 아 왜...

 

Github Support 페이지에 접속해서 SMS 확인코드를 보내고 문의함

https://support.github.com/verification/sms_verification

 

Sign in for Software Support and Product Help - GitHub 지원

 

support.github.com

 

깃허브 복구 페이지

 

 

GitHub를 선택하고, 로그인 할 수 있지만 나의 프로필 및 기여가 다른 사람에게 표시되지않음을 선택함

 

나는 스팸 계정이 아니고 실제 개발자이며, 서비스를 배포하려는데 에러가 난다
깃허브 자체 로그인은 되는데 https://supabase.com/에서 깃허브로 로그인을 시도하면
"This account is flagged..." 에러가 뜬다를 정리하여 전송함.

더보기

제목: Appeal for account flag: Unable to authorize third-party application (Supabase)

 

본문: Hello GitHub Support Team,

I am a solo developer working on a new web service project. Recently, I found that my account has been flagged, which prevents me from authorizing third-party applications.

Specifically, I am unable to log in to Supabase (https://supabase.com) using my GitHub account, receiving the error message: "This account is flagged, and therefore cannot authorize a third-party application."

I am a real user, not a spam bot. I have already enabled Two-Factor Authentication (2FA) and verified my email to secure my account. I need to integrate GitHub with Supabase and Vercel to deploy my project.

Could you please review my account and lift the flag?

Thank you for your help. Best regards, 깃허브ID

 

다행히 바로 답이 왔다.

깃허브 지원팀 답메일

 

시스템이 가끔 오해한단다. 제한 풀어줬으니 자유롭게 쓰란다 후후

Supabase에서 프로젝트를 담을 Org만들기

 

New Project 설정

 

Region 한국사용자가 접속할 때 속도가 가장 빠름

RLS는 개발할 때 데이터가 안보일 수 있으니 나중에 필요할 때 켜는게 정신건강에 좋..

데이터 테이블 생성 수

 

어차피 생년월일과 시간까지 입력해야 해서 하나의 객체로 묶어서 관리하기로 함

jsonb라는 타입이 있어서 컬럼 하나에 여러 데이터를 넣을 수 있게 됨

사용자 입력값이랑 AI결과값만 두덩어리로 관리되게 함

 

환경변수를 설정해야하는데 이전에 구글api연결하던 파일에 

Supabase프로젝트 URL과, Public key를 박아 넣는다.

# Supabase 프로젝트 URL (대시보드 Home에서 복사)
NEXT_PUBLIC_SUPABASE_URL=https://your-project-id.supabase.co

# Supabase Anon Key (API Keys 메뉴의 anon/public)
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here

 

 

DB연결할 파일 추가 (lib/supabase.js)

import { createClient } from '@supabase/supabase-js'

const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY

// 프로젝트 전체에서 공유할 Supabase 클라이언트 생성
export const supabase = createClient(supabaseUrl, supabaseAnonKey)

 

이제 캐시 관련 추가코드 수정

// =========================
    // 💾 DB 기록 및 캐시 저장
    // =========================
    try {
      const { error } = await supabase
        .from("saju_results")
        .insert([
          {
            user_info: {
              year: saju.year,
              month: saju.month,
              day: saju.day,
              hour: saju.hour,
              gender: gender,
            },
            saju_content: text,
            cache_key: cacheKey
          }
        ]);

      if (error) {
        console.error("❌ Supabase 저장 실패:", error.message);
      } else {
        console.log("✅ 사주 결과 DB 저장 완료!");
      }
    } catch (dbError) {
      console.error("❌ DB 로직 에러:", dbError);
    }

    // 최종 결과 반환
    return NextResponse.json({
      candidates: [{ content: { parts: [{ text }] } }]
    });

  } catch (error: any) {
    console.error("❌ 서버 에러:", error);
    return NextResponse.json({ error: "서버 내부 오류", details: error.message }, { status: 500 });
  }
}

 

코드 수정하고 결과값은 잘 나오는데, DB연결이 한동안 안되어서 터미널 보고 에러를 찾았다

 

RLS에러는 아래 SQL코드로 해

alter table saju_results disable row level security;

 

작동 잘하는 내새뀌..

 

이젠 배포를 해야겠죠....

일반적인 웹호스팅으론 배포가 불가하므로 다시 제작노트를 쓰도록 하겠습니다 

반응형