Reverted to edit edt-5621e5a0-bf01-45d1-871d-f401b7a23641: "Investigate fetch failure

Investigate why fetch requests are failing."
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 07:29:30 +00:00
parent 21cfc7aee2
commit 46d4f10c5c
2 changed files with 64 additions and 25 deletions

View File

@@ -4,7 +4,7 @@ import { createClient } from '@supabase/supabase-js';
// Supabase URL과 anon key 설정
// 브라우저에서 CORS 문제가 자주 발생하므로 HTTPS URL로 변경
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL || 'https://tzmywjqtluhwemhuflhi.supabase.co';
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY || 'yQKSViIU5I2/QTbTN93GnGxKC+Ny3KPE+gDhrMzlhG0=';
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InR6bXl3anF0bHVod2VtaHVmbGhpIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDk1NDUzMTUsImV4cCI6MjAyNTEyMTMxNX0.iCPZvMm9KeRjxh2cE-rkpAIxf9XpZzGIpSZBXBSRfoU';
// 유효한 URL이 설정되었는지 확인
const isValidUrl = supabaseUrl && supabaseAnonKey &&

View File

@@ -6,6 +6,7 @@ import { Button } from "@/components/ui/button";
import { ArrowRight, Mail, KeyRound, User, Eye, EyeOff } from "lucide-react";
import { useToast } from "@/hooks/useToast.wrapper";
import { useAuth } from "@/contexts/auth";
const Register = () => {
const [username, setUsername] = useState("");
const [email, setEmail] = useState("");
@@ -13,45 +14,43 @@ const Register = () => {
const [confirmPassword, setConfirmPassword] = useState("");
const [showPassword, setShowPassword] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const {
toast
} = useToast();
const { toast } = useToast();
const navigate = useNavigate();
const {
signUp,
user
} = useAuth();
const { signUp, user } = useAuth();
// 이미 로그인된 경우 메인 페이지로 리다이렉트
useEffect(() => {
if (user) {
navigate("/");
}
}, [user, navigate]);
const handleRegister = async (e: React.FormEvent) => {
e.preventDefault();
if (!username || !email || !password || !confirmPassword) {
toast({
title: "입력 오류",
description: "모든 필드를 입력해주세요.",
variant: "destructive"
variant: "destructive",
});
return;
}
if (password !== confirmPassword) {
toast({
title: "비밀번호 불일치",
description: "비밀번호와 비밀번호 확인이 일치하지 않습니다.",
variant: "destructive"
variant: "destructive",
});
return;
}
setIsLoading(true);
try {
const {
error,
user
} = await signUp(email, password, username);
const { error, user } = await signUp(email, password, username);
if (!error && user) {
// 데모 모드에서는 즉시 메인 페이지로 이동
navigate("/");
@@ -62,10 +61,12 @@ const Register = () => {
setIsLoading(false);
}
};
return <div className="min-h-screen flex flex-col items-center justify-center p-6 bg-neuro-background">
return (
<div className="min-h-screen flex flex-col items-center justify-center p-6 bg-neuro-background">
<div className="w-full max-w-md">
<div className="text-center mb-8">
<h1 className="text-3xl font-bold text-neuro-income mb-2"> </h1>
<h1 className="text-3xl font-bold text-neuro-income mb-2"> </h1>
<p className="text-gray-500"> </p>
</div>
@@ -76,7 +77,14 @@ const Register = () => {
<Label htmlFor="username" className="text-base"></Label>
<div className="relative">
<User className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 h-5 w-5" />
<Input id="username" type="text" placeholder="홍길동" value={username} onChange={e => setUsername(e.target.value)} className="pl-10 neuro-pressed" />
<Input
id="username"
type="text"
placeholder="홍길동"
value={username}
onChange={(e) => setUsername(e.target.value)}
className="pl-10 neuro-pressed"
/>
</div>
</div>
@@ -84,7 +92,14 @@ const Register = () => {
<Label htmlFor="email" className="text-base"></Label>
<div className="relative">
<Mail className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 h-5 w-5" />
<Input id="email" type="email" placeholder="your@email.com" value={email} onChange={e => setEmail(e.target.value)} className="pl-10 neuro-pressed" />
<Input
id="email"
type="email"
placeholder="your@email.com"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="pl-10 neuro-pressed"
/>
</div>
</div>
@@ -92,8 +107,19 @@ const Register = () => {
<Label htmlFor="password" className="text-base"></Label>
<div className="relative">
<KeyRound className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 h-5 w-5" />
<Input id="password" type={showPassword ? "text" : "password"} placeholder="••••••••" value={password} onChange={e => setPassword(e.target.value)} className="pl-10 neuro-pressed" />
<button type="button" onClick={() => setShowPassword(!showPassword)} className="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500">
<Input
id="password"
type={showPassword ? "text" : "password"}
placeholder="••••••••"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="pl-10 neuro-pressed"
/>
<button
type="button"
onClick={() => setShowPassword(!showPassword)}
className="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-500"
>
{showPassword ? <EyeOff className="h-5 w-5" /> : <Eye className="h-5 w-5" />}
</button>
</div>
@@ -103,11 +129,22 @@ const Register = () => {
<Label htmlFor="confirmPassword" className="text-base"> </Label>
<div className="relative">
<KeyRound className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500 h-5 w-5" />
<Input id="confirmPassword" type={showPassword ? "text" : "password"} placeholder="••••••••" value={confirmPassword} onChange={e => setConfirmPassword(e.target.value)} className="pl-10 neuro-pressed" />
<Input
id="confirmPassword"
type={showPassword ? "text" : "password"}
placeholder="••••••••"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
className="pl-10 neuro-pressed"
/>
</div>
</div>
<Button type="submit" className="w-full bg-neuro-income hover:bg-neuro-income/80 text-white py-6 h-auto" disabled={isLoading}>
<Button
type="submit"
className="w-full bg-neuro-income hover:bg-neuro-income/80 text-white py-6 h-auto"
disabled={isLoading}
>
{isLoading ? "가입 중..." : "회원가입"} {!isLoading && <ArrowRight className="ml-2 h-5 w-5" />}
</Button>
</div>
@@ -123,6 +160,8 @@ const Register = () => {
</p>
</div>
</div>
</div>;
</div>
);
};
export default Register;
export default Register;