Ensure user sessions persist correctly and securely across the platform
Implements CORS and updates AuthContext to manage user authentication via cookie-based sessions. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 8fac8604-8776-4090-bf16-1e3d01acb719 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/9777c70b-fc38-4831-8d6b-78dfffe041b0/e43769e0-ea3b-4deb-b53a-a84e46de587b.jpg
This commit is contained in:
@@ -27,10 +27,21 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
|
||||
const checkAuthStatus = async () => {
|
||||
try {
|
||||
const currentUser = await authService.getCurrentUser();
|
||||
setUser(currentUser);
|
||||
const response = await fetch('/api/auth/me', {
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
setUser(data.user);
|
||||
} else {
|
||||
setUser(null);
|
||||
}
|
||||
} catch (error) {
|
||||
// User not authenticated
|
||||
console.warn('Auth check failed:', error);
|
||||
setUser(null);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user