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