import axios from 'axios'; // 1. Base URL set to relative '/api' // This means if your site is at https://myspace.hf.space, // requests automatically go to https://myspace.hf.space/api const api = axios.create({ baseURL: '/api', withCredentials: true, headers: { 'Content-Type': 'application/json', }, }); export const authAPI = { register: (data) => api.post('/auth/register', data), login: (data) => api.post('/auth/login', data), logout: () => api.post('/auth/logout'), getCurrentUser: () => api.get('/auth/me'), googleLogin: () => { // 2. Google Login set to relative path // Redirects to /api/auth/google on the current domain window.location.href = '/api/auth/google'; }, }; export const roomAPI = { createRoom: (data) => api.post('/rooms/create', data), getRoom: (roomId) => api.get(`/rooms/${roomId}`), joinRoom: (roomId) => api.post(`/rooms/${roomId}/join`), endRoom: (roomId) => api.post(`/rooms/${roomId}/end`), getUserRooms: () => api.get('/rooms/user/rooms'), }; export default api;