import axios from 'axios';

export const checkAuth = async () => {
  try {
    const { data } = await axios.get(
      `${import.meta.env.VITE_BACK_URL}/api/auth/check`,
      {
        withCredentials: true,
        headers: {
          'Authorization': `Bearer ${localStorage.getItem('access_token') || ''}`,
        },
      }
    );

    return data;
  } catch (err) {
    console.error('Auth check failed:', err);
    return { isAuthenticated: false };
  }
};