Fix public access mode, introduce loading spinners, package fixes

This commit is contained in:
Alexander R.
2026-07-22 18:00:15 +00:00
parent 0b7259a011
commit b669d2e799
197 changed files with 698 additions and 20961 deletions
+36 -3
View File
@@ -1,8 +1,18 @@
import axios from 'axios';
const apiHost = typeof window !== 'undefined' && window.location.hostname ? window.location.hostname : '127.0.0.1';
const apiClient = axios.create({
baseURL: `http://${apiHost}:8000`,
const getApiBaseUrl = () => {
if (import.meta.env.VITE_API_BASE_URL) {
return import.meta.env.VITE_API_BASE_URL;
}
// Use relative path in browser so requests are routed via Vite proxy or reverse proxy
if (typeof window !== 'undefined') {
return '';
}
return 'http://127.0.0.1:8000';
};
export const apiClient = axios.create({
baseURL: getApiBaseUrl(),
headers: {
'Content-Type': 'application/json',
},
@@ -86,3 +96,26 @@ export const getHandbookExample = async (
});
return response.data;
};
export const generateChallenge = async (
prompt: string,
language: string,
difficulty: string,
subject: string
) => {
const response = await apiClient.post('/challenges/generate', {
prompt,
language,
difficulty,
subject,
});
return response.data;
};
export const saveChallenge = async (filename: string, markdown: string) => {
const response = await apiClient.post('/challenges/save', {
filename,
markdown,
});
return response.data;
};