Add choices API endpoint and OpenAPI client setup
Introduces a new /api/choices/ endpoint for fetching model choices with multilingual labels. Updates Django models to use 'cz#' prefix for Czech labels. Adds OpenAPI client generation via orval, refactors frontend API structure, and provides documentation and helper scripts for dynamic choices and OpenAPI usage.
This commit is contained in:
27
frontend/src/api/privateClient.ts
Normal file
27
frontend/src/api/privateClient.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import axios from "axios";
|
||||
|
||||
// použij tohle pro API vyžadující autentizaci
|
||||
export const privateApi = axios.create({
|
||||
baseURL: "/api/",
|
||||
withCredentials: true, // potřebuje HttpOnly cookies
|
||||
});
|
||||
|
||||
privateApi.interceptors.response.use(
|
||||
(res) => res,
|
||||
async (error) => {
|
||||
const original = error.config;
|
||||
|
||||
if (error.response?.status === 401 && !original._retry) {
|
||||
original._retry = true;
|
||||
|
||||
try {
|
||||
await privateApi.post("/auth/refresh/");
|
||||
return privateApi(original);
|
||||
} catch {
|
||||
// optional: logout
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user