Update CORS proxy configuration

This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 15:41:32 +00:00
parent 0f4f426dd4
commit 1c3c4f37e0
5 changed files with 76 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
import { supabase } from '@/lib/supabase';
import { getProxyType, isCorsProxyEnabled } from '@/lib/supabase/config';
/**
* CORS 문제 확인
@@ -37,6 +38,11 @@ export const verifyServerConnection = async (): Promise<{
};
}
// 프록시 설정 상태 확인
const usingProxy = isCorsProxyEnabled();
const proxyType = getProxyType();
console.log(`연결 테스트 - CORS 프록시: ${usingProxy ? '사용 중' : '미사용'}, 타입: ${proxyType}`);
// 단순 헬스 체크 요청
try {
const response = await fetch(`${supabaseUrl}/auth/v1/`, {
@@ -92,6 +98,10 @@ export const verifyServerConnection = async (): Promise<{
} catch (error: any) {
console.error('서버 연결 확인 중 오류:', error);
// 프록시 설정 확인
const usingProxy = isCorsProxyEnabled();
const proxyType = getProxyType();
// 오류 유형에 따른 메시지 설정
let errorMessage = '알 수 없는 네트워크 오류';
@@ -111,6 +121,15 @@ export const verifyServerConnection = async (): Promise<{
}
}
// Cloudflare 프록시 추천 메시지 추가
if (errorMessage.includes('CORS') || errorMessage.includes('fetch') || errorMessage.includes('네트워크')) {
if (!usingProxy) {
console.log('CORS 오류 감지, Cloudflare 프록시 사용 권장');
} else if (proxyType !== 'cloudflare') {
console.log('CORS 오류 감지, Cloudflare 프록시로 변경 권장');
}
}
return {
connected: false,
message: errorMessage