Версия 0.2.2. Исправлен настройки на backend, чтобы работало в Docker при заходе в приложение с хоста.
This commit is contained in:
parent
a05a0af6c1
commit
d3c320169d
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "lawn-mowing-scheduler",
|
"name": "lawn-mowing-scheduler",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently \"npm run server\" \"npm run client\"",
|
"dev": "concurrently \"npm run server\" \"npm run client\"",
|
||||||
|
@ -10,6 +10,8 @@ interface ZoneCardProps {
|
|||||||
onDelete: (id: number) => void;
|
onDelete: (id: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const API_BASE = import.meta.env.VITE_API_URL;
|
||||||
|
|
||||||
const ZoneCard: React.FC<ZoneCardProps> = ({
|
const ZoneCard: React.FC<ZoneCardProps> = ({
|
||||||
zone,
|
zone,
|
||||||
onMarkAsMowed,
|
onMarkAsMowed,
|
||||||
@ -99,7 +101,7 @@ const ZoneCard: React.FC<ZoneCardProps> = ({
|
|||||||
{zone.imagePath ? (
|
{zone.imagePath ? (
|
||||||
<div className="relative h-48 overflow-hidden rounded-t-lg">
|
<div className="relative h-48 overflow-hidden rounded-t-lg">
|
||||||
<img
|
<img
|
||||||
src={`http://localhost:3001${zone.imagePath}`}
|
src={`${API_BASE}${zone.imagePath}`}
|
||||||
alt={zone.name}
|
alt={zone.name}
|
||||||
className="w-full h-full object-cover"
|
className="w-full h-full object-cover"
|
||||||
/>
|
/>
|
||||||
|
@ -9,6 +9,8 @@ interface ZoneFormProps {
|
|||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const API_BASE = import.meta.env.VITE_API_URL;
|
||||||
|
|
||||||
const ZoneForm: React.FC<ZoneFormProps> = ({ zone, onSubmit, onCancel }) => {
|
const ZoneForm: React.FC<ZoneFormProps> = ({ zone, onSubmit, onCancel }) => {
|
||||||
const [formData, setFormData] = useState<ZoneFormData>({
|
const [formData, setFormData] = useState<ZoneFormData>({
|
||||||
name: zone?.name || '',
|
name: zone?.name || '',
|
||||||
@ -19,7 +21,7 @@ const ZoneForm: React.FC<ZoneFormProps> = ({ zone, onSubmit, onCancel }) => {
|
|||||||
area: zone?.area || 0,
|
area: zone?.area || 0,
|
||||||
});
|
});
|
||||||
const [imagePreview, setImagePreview] = useState<string | null>(
|
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 [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
@ -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 = {
|
export const api = {
|
||||||
async getZones(): Promise<Zone[]> {
|
async getZones(): Promise<Zone[]> {
|
||||||
|
@ -1,19 +1,25 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig, loadEnv } from 'vite';
|
||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
export default defineConfig(({ mode }) => {
|
||||||
export default defineConfig({
|
const env = loadEnv(mode, process.cwd());
|
||||||
plugins: [react()],
|
|
||||||
optimizeDeps: {
|
return {
|
||||||
exclude: ['lucide-react'],
|
plugins: [react()],
|
||||||
},
|
esbuild: {
|
||||||
server: {
|
minifyIdentifiers: false, // Отключаем переименование переменных
|
||||||
host: true, // <-- добавлено: позволяет Vite принимать запросы извне (из Nginx)
|
},
|
||||||
proxy: {
|
optimizeDeps: {
|
||||||
'/api': {
|
exclude: ['lucide-react'],
|
||||||
target: 'http://localhost:3001',
|
},
|
||||||
changeOrigin: true,
|
server: {
|
||||||
|
host: true, // <-- добавлено: позволяет Vite принимать запросы извне (из Nginx)
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: env.VITE_API_URL || 'http://localhost:3001',
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user