Версия 0.2.2. Исправлен настройки на backend, чтобы работало в Docker при заходе в приложение с хоста.

This commit is contained in:
anibilag 2025-07-09 14:01:07 +03:00
parent a05a0af6c1
commit d3c320169d
5 changed files with 29 additions and 19 deletions

View File

@ -1,7 +1,7 @@
{
"name": "lawn-mowing-scheduler",
"private": true,
"version": "0.2.1",
"version": "0.2.2",
"type": "module",
"scripts": {
"dev": "concurrently \"npm run server\" \"npm run client\"",

View File

@ -10,6 +10,8 @@ interface ZoneCardProps {
onDelete: (id: number) => void;
}
const API_BASE = import.meta.env.VITE_API_URL;
const ZoneCard: React.FC<ZoneCardProps> = ({
zone,
onMarkAsMowed,
@ -99,7 +101,7 @@ const ZoneCard: React.FC<ZoneCardProps> = ({
{zone.imagePath ? (
<div className="relative h-48 overflow-hidden rounded-t-lg">
<img
src={`http://localhost:3001${zone.imagePath}`}
src={`${API_BASE}${zone.imagePath}`}
alt={zone.name}
className="w-full h-full object-cover"
/>

View File

@ -9,6 +9,8 @@ interface ZoneFormProps {
onCancel: () => void;
}
const API_BASE = import.meta.env.VITE_API_URL;
const ZoneForm: React.FC<ZoneFormProps> = ({ zone, onSubmit, onCancel }) => {
const [formData, setFormData] = useState<ZoneFormData>({
name: zone?.name || '',
@ -19,7 +21,7 @@ const ZoneForm: React.FC<ZoneFormProps> = ({ zone, onSubmit, onCancel }) => {
area: zone?.area || 0,
});
const [imagePreview, setImagePreview] = useState<string | null>(
zone?.imagePath ? `http://localhost:3001${zone.imagePath}` : null
zone?.imagePath ? `${API_BASE}${zone.imagePath}` : null
);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);

View File

@ -1,6 +1,6 @@
import { Zone, ZoneFormData, MowingHistory, MowingHistoryResponse, MowingStats, MowingFormData, Mower, MowerFormData, BulkMowingFormData } from '../types/zone';
import { Zone, ZoneFormData, MowingHistoryResponse, MowingStats, MowingFormData, Mower, MowerFormData, BulkMowingFormData } from '../types/zone';
const API_BASE = 'http://localhost:3001/api';
const API_BASE = new URL('api', import.meta.env.VITE_API_URL).toString();
export const api = {
async getZones(): Promise<Zone[]> {

View File

@ -1,9 +1,14 @@
import { defineConfig } from 'vite';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
// https://vitejs.dev/config/
export default defineConfig({
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
return {
plugins: [react()],
esbuild: {
minifyIdentifiers: false, // Отключаем переименование переменных
},
optimizeDeps: {
exclude: ['lucide-react'],
},
@ -11,9 +16,10 @@ export default defineConfig({
host: true, // <-- добавлено: позволяет Vite принимать запросы извне (из Nginx)
proxy: {
'/api': {
target: 'http://localhost:3001',
target: env.VITE_API_URL || 'http://localhost:3001',
changeOrigin: true,
},
},
},
}
});