diff --git a/.env.example b/.env.example index 02d246f..92f4fa3 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,2 @@ -VITE_API_BASE_URL=http://localhost:8000/api/v1 +VITE_API_BASE_URL=http://127.0.0.1:8000/api/v1 VITE_YANDEX_MAPS_API_KEY= diff --git a/README.md b/README.md index 483bda7..1175b0e 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ Для локальной разработки backend обычно доступен по адресу: ```text -http://localhost:8000/api/v1 +http://127.0.0.1:8000/api/v1 ``` ## Локальный запуск @@ -121,7 +121,7 @@ VITE_YANDEX_MAPS_API_KEY=your-yandex-maps-api-key Если переменная не задана: -- на `localhost` приложение использует `http://localhost:8000/api/v1` +- на `localhost` приложение использует `http://127.0.0.1:8000/api/v1` - на остальных доменах приложение использует относительный путь `/api/v1` Ручного поля `API Base` в интерфейсе нет: конечный пользователь не должен настраивать backend-адрес внутри UI. diff --git a/src/api/http.ts b/src/api/http.ts index 8ed8f5c..5911bb6 100644 --- a/src/api/http.ts +++ b/src/api/http.ts @@ -13,7 +13,7 @@ function detectDefaultApiBase() { if (typeof window !== 'undefined') { const host = window.location.hostname; if (host === 'localhost' || host === '127.0.0.1') { - return 'http://localhost:8000/api/v1'; + return 'http://127.0.0.1:8000/api/v1'; } } diff --git a/src/components/ZoneMapSelector.tsx b/src/components/ZoneMapSelector.tsx index 089ffb3..fe32d99 100644 --- a/src/components/ZoneMapSelector.tsx +++ b/src/components/ZoneMapSelector.tsx @@ -64,7 +64,7 @@ function YandexZoneGeometryMap({ }) { const mapRef = useRef(null); const pointsRef = useRef(points); - const { ymaps, map, loading, error } = useYandexMap(mapRef, { center, zoom: 16 }); + const { ymaps, map, loading, error } = useYandexMap(mapRef, { center, zoom: 16, syncView: false }); useEffect(() => { pointsRef.current = points; diff --git a/src/maps/useYandexMap.ts b/src/maps/useYandexMap.ts index e372263..58cc7f7 100644 --- a/src/maps/useYandexMap.ts +++ b/src/maps/useYandexMap.ts @@ -5,6 +5,7 @@ type UseYandexMapOptions = { center: YandexPoint; zoom: number; controls?: string[]; + syncView?: boolean; }; type YandexMapState = { @@ -16,7 +17,7 @@ type YandexMapState = { export function useYandexMap( containerRef: RefObject, - { center, zoom, controls = ['zoomControl'] }: UseYandexMapOptions + { center, zoom, controls = ['zoomControl'], syncView = true }: UseYandexMapOptions ) { const [state, setState] = useState({ loading: true }); const centerKey = useMemo(() => center.join(','), [center]); @@ -55,9 +56,9 @@ export function useYandexMap( }, []); useEffect(() => { - if (!state.map) return; + if (!syncView || !state.map) return; state.map.setCenter(center, zoom, { duration: 200 }); - }, [state.map, centerKey, zoom]); + }, [state.map, centerKey, zoom, syncView]); return state; } diff --git a/src/store/useStore.ts b/src/store/useStore.ts index 5bcae12..8c3f886 100644 --- a/src/store/useStore.ts +++ b/src/store/useStore.ts @@ -22,7 +22,7 @@ function detectDefaultApiBase() { if (typeof window !== 'undefined') { const host = window.location.hostname; if (host === 'localhost' || host === '127.0.0.1') { - return 'http://localhost:8000/api/v1'; + return 'http://127.0.0.1:8000/api/v1'; } }