-
Notifications
You must be signed in to change notification settings - Fork 262
Open
Description
When implementing protected routes in a React application using Supabase authentication, users are experiencing connection refused errors with the message "project-id.supabase.co refused to connect". This occurs specifically after adding protected route functionality and affects the application's ability to authenticate users.
Steps to Reproduce
- Set up a new React + Vite project with Supabase authentication
- Implement protected routes using React Router
- Configure Supabase client with authentication
- Attempt to access a protected route
- Connection is refused with the error: "project-id. superbase.co refused to connect"
Expected Behavior
- Protected routes should properly authenticate with Supabase
- No connection refused errors should occur
- Smooth transition between public and protected routes
Actual Behavior
- Connection to Supabase is being refused
- Authentication flow is broken
- Users cannot access protected routes
- Application becomes unresponsive
Environment
- React 18.3.1
- Vite 5.4.2
- @supabase/supabase-js latest
- React Router DOM 6.22.2
- Browser: Latest Chrome/Firefox
- OS: Windows/Mac/Linux
Relevant Code
The issue appears after implementing the following authentication flow:
// ProtectedRoute.tsx
export function ProtectedRoute({ children }: ProtectedRouteProps) {
const { user, initialized } = useAuthStore();
const location = useLocation();
if (!initialized) {
return <LoadingSpinner />;
}
if (!user) {
return <Navigate to="/login" state={{ from: location }} replace />;
}
return <>{children}</>;
}Metadata
Metadata
Assignees
Labels
No labels