Initial project scaffold: FastAPI + React/Vite + PostgreSQL SaaS starter
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import axios from "axios";
|
||||
|
||||
const api = axios.create({ baseURL: "/api" });
|
||||
|
||||
api.interceptors.request.use((config) => {
|
||||
const token = localStorage.getItem("token");
|
||||
if (token) config.headers.Authorization = `Bearer ${token}`;
|
||||
return config;
|
||||
});
|
||||
|
||||
export default api;
|
||||
|
||||
// --- Auth ---
|
||||
export const login = (email: string, password: string) =>
|
||||
api
|
||||
.post<{ access_token: string }>("/auth/login", new URLSearchParams({ username: email, password }))
|
||||
.then((r) => r.data.access_token);
|
||||
|
||||
export const register = (email: string, password: string, full_name?: string) =>
|
||||
api.post("/auth/register", { email, password, full_name }).then((r) => r.data);
|
||||
|
||||
// --- Users ---
|
||||
export const getMe = () => api.get("/users/me").then((r) => r.data);
|
||||
Reference in New Issue
Block a user