feat: implement authentication and core API endpoints - auth, podcasts, episodes

This commit is contained in:
Michael committed 2026-04-16 09:55:15 +02:00
1 parent 8df1161023
commit 8c00a1b0f5
13 files changed
+822 -1

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import axios from 'axios';
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:5000/api';
const api = axios.create({
baseURL: API_URL,
headers: {
'Content-Type': 'application/json',
},
});
// Add auth token to requests
api.interceptors.request.use((config) => {
const token = localStorage.getItem('accessToken');
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});
// Handle token refresh on 401
api.interceptors.response.use(
(response) => response,
async (error) => {
if (error.response?.status === 401) {
// Token expired - could implement refresh token logic here
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
window.location.href = '/login';
}
return Promise.reject(error);
}
);
export default api;