6520ebf221
Self-hosted, plugin-extensible personal finance manager built with ASP.NET Core 9.0, Vue 3 + Vuetify 3, and PostgreSQL 17. Backend (8 .NET projects): - Core: 19 domain models, 6 enums, 14 DTOs, 12 service interfaces - Data: EF Core DbContext, 16 entity configurations, category seeder - API: 14 controllers, 15 services, JWT auth, SignalR, middleware - Plugins: Abstractions + OFX/CSV/QIF file parsers - Tests: 28 xUnit tests (fingerprinting, duplicate detection, parsers) Frontend (Vue 3 + Vuetify 3 + TypeScript): - 13 views, Pinia stores, Axios API services with JWT interceptors - Dashboard, accounts, transactions, categories, imports, and more Deployment: - Docker Compose (PostgreSQL 17 + .NET API + nginx frontend) - Auto-migration on startup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
37 lines
848 B
TypeScript
37 lines
848 B
TypeScript
import axios from 'axios'
|
|
import { useAuthStore } from '@/stores/auth'
|
|
import router from '@/router'
|
|
|
|
const api = axios.create({
|
|
baseURL: '/api',
|
|
headers: { 'Content-Type': 'application/json' }
|
|
})
|
|
|
|
api.interceptors.request.use(config => {
|
|
const authStore = useAuthStore()
|
|
if (authStore.token) {
|
|
config.headers.Authorization = `Bearer ${authStore.token}`
|
|
}
|
|
return config
|
|
})
|
|
|
|
api.interceptors.response.use(
|
|
response => response,
|
|
async error => {
|
|
if (error.response?.status === 401) {
|
|
const authStore = useAuthStore()
|
|
try {
|
|
await authStore.refreshToken()
|
|
error.config.headers.Authorization = `Bearer ${authStore.token}`
|
|
return api(error.config)
|
|
} catch {
|
|
authStore.logout()
|
|
router.push('/login')
|
|
}
|
|
}
|
|
return Promise.reject(error)
|
|
}
|
|
)
|
|
|
|
export default api
|