Investigate Supabase connection issues

Investigate REST API and database connection failures despite successful authentication.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 12:28:18 +00:00
parent 6de30b681a
commit ae1db90d87
4 changed files with 207 additions and 28 deletions

View File

@@ -1,9 +1,10 @@
import React, { useState } from 'react';
import { Button } from "@/components/ui/button";
import { RefreshCw } from "lucide-react";
import { RefreshCw, Info } from "lucide-react";
import { toast } from "@/hooks/useToast.wrapper";
import { testSupabaseConnection } from '@/lib/supabase';
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
interface TestResult {
url: string;
@@ -14,11 +15,13 @@ interface TestResult {
auth: boolean;
database: boolean;
errors: string[];
debugInfo?: any;
}
const SupabaseConnectionTest: React.FC = () => {
const [testResults, setTestResults] = useState<TestResult | null>(null);
const [isTesting, setIsTesting] = useState(false);
const [showDebug, setShowDebug] = useState(false);
const runConnectionTest = async () => {
setIsTesting(true);
@@ -107,6 +110,59 @@ const SupabaseConnectionTest: React.FC = () => {
))}
</div>
)}
{/* 디버그 정보 섹션 추가 */}
{testResults.debugInfo && (
<Collapsible
open={showDebug}
onOpenChange={setShowDebug}
className="border border-gray-200 rounded-md mt-4"
>
<div className="flex items-center justify-between px-4 py-2 bg-gray-50">
<h4 className="text-sm font-medium"> </h4>
<CollapsibleTrigger asChild>
<Button variant="ghost" size="sm" className="h-7 w-7 p-0">
<Info className="h-4 w-4" />
<span className="sr-only">
{showDebug ? '진단 정보 숨기기' : '진단 정보 표시'}
</span>
</Button>
</CollapsibleTrigger>
</div>
<CollapsibleContent className="px-4 py-2 text-xs">
<div className="space-y-2">
<div>
<span className="font-medium">Supabase URL:</span>
<div className="mt-1 bg-gray-100 p-1 rounded break-all">
{testResults.url}
</div>
</div>
<div>
<span className="font-medium"> :</span>
<div className="mt-1 text-green-600">
{testResults.client ? '성공' : '실패'}
</div>
</div>
<div>
<span className="font-medium"> :</span>
<div className="mt-1 bg-gray-100 p-1 rounded break-all">
{testResults.debugInfo.browserInfo}
</div>
</div>
<div>
<span className="font-medium"> :</span>
<div className="mt-1">
{new Date(testResults.debugInfo.timestamp).toLocaleString()}
</div>
</div>
</div>
</CollapsibleContent>
</Collapsible>
)}
</div>
)}
</div>

View File

@@ -1,5 +1,6 @@
import React from 'react';
import { AlertCircle } from 'lucide-react';
const SupabaseHelpSection: React.FC = () => {
return (
@@ -17,12 +18,35 @@ const SupabaseHelpSection: React.FC = () => {
<strong>Anon Key</strong>: Supabase API anon/public .
</li>
<li>
<strong>CORS </strong>: HTTP URL에 . HTTPS가 URL에 .
<strong>CORS </strong>: HTTP URL에 .
HTTPS가 URL에 .
</li>
<li className="text-amber-500 font-medium">
HTTPS URL을 . HTTP URL을 CORS .
</li>
</ul>
{/* 오류 해결 팁 추가 */}
<div className="mt-6 border-t pt-4">
<h3 className="flex items-center text-sm font-semibold mb-2">
<AlertCircle className="h-4 w-4 mr-1 text-amber-500" />
<span> </span>
</h3>
<ul className="list-disc pl-5 text-xs text-gray-500 space-y-2">
<li>
<strong>REST API </strong>: CORS . Supabase CORS .
</li>
<li>
<strong> , API </strong>: CORS . CORS .
</li>
<li>
<strong> </strong>: Supabase , .
</li>
<li>
<strong>HTTPS </strong>: HTTP , HTTPS Supabase URL이 .
</li>
</ul>
</div>
</div>
);
};