Fix: Use api instance instead of direct axios in Templates.jsx

This commit is contained in:
salvacybersec
2025-11-11 05:51:26 +03:00
parent 1a45487cf1
commit df203b6f32

View File

@@ -34,9 +34,7 @@ import {
} from '@mui/icons-material'; } from '@mui/icons-material';
import { templateService } from '../services/templateService'; import { templateService } from '../services/templateService';
import { format } from 'date-fns'; import { format } from 'date-fns';
import axios from 'axios'; import api from '../services/api';
const API_URL = import.meta.env.VITE_API_URL;
const defaultForm = { const defaultForm = {
name: '', name: '',
@@ -83,9 +81,7 @@ function Templates() {
const loadThemes = async () => { const loadThemes = async () => {
try { try {
const response = await axios.get(`${API_URL}/api/ollama/themes`, { const response = await api.get('/api/ollama/themes');
withCredentials: true,
});
setAvailableThemes(response.data.data.themes); setAvailableThemes(response.data.data.themes);
} catch (error) { } catch (error) {
console.error('Failed to load themes:', error); console.error('Failed to load themes:', error);
@@ -188,8 +184,8 @@ function Templates() {
setAiGenerating(true); setAiGenerating(true);
try { try {
const response = await axios.post( const response = await api.post(
`${API_URL}/api/ollama/generate-template`, '/api/ollama/generate-template',
aiForm, aiForm,
{ withCredentials: true } { withCredentials: true }
); );
@@ -223,8 +219,8 @@ function Templates() {
} }
try { try {
await axios.post( await api.post(
`${API_URL}/api/ollama/send-test-mail`, '/api/ollama/send-test-mail',
{ {
test_email: testMailAddress, test_email: testMailAddress,
subject: selectedTemplate.subject_template, subject: selectedTemplate.subject_template,