From 9e16a0966f2189da18b166f5d312d7d1aafdae31 Mon Sep 17 00:00:00 2001 From: shats Date: Wed, 27 Aug 2025 15:24:59 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D1=83=20=D0=BA?= =?UTF-8?q?=D1=8D=D1=88=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=20GET,=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=B2=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20/communities,=20=D1=87=D1=82=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B=20=D0=B2=D1=81=D0=B5=D0=B3=D0=B4=D0=B0=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D1=88=D0=B8=D0=B2=D0=B0=D1=82=D1=8C=20=D1=81?= =?UTF-8?q?=D0=B2=D0=B5=D0=B6=D0=B8=D0=B5=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=B8=20=D1=83=D0=BB=D1=83=D1=87=D1=88=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D1=83?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B3=D0=BE=D0=BB=D0=BE=D0=B2=D0=BA=D0=BE=D0=B2?= =?UTF-8?q?=20If-None-Match?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lib/api.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/frontend/src/lib/api.js b/frontend/src/lib/api.js index 6116e9e..58703a9 100644 --- a/frontend/src/lib/api.js +++ b/frontend/src/lib/api.js @@ -87,11 +87,21 @@ api.interceptors.request.use((config) => { // If-None-Match для GET на базе кеша const method = String(config.method || 'get').toLowerCase(); if (method === 'get') { - const key = buildCacheKey(config); - const cached = responseCache.get(key); - if (cached?.etag) { - config.headers = config.headers || {}; - if (!config.headers['If-None-Match']) config.headers['If-None-Match'] = String(cached.etag); + // Исключение: для /communities всегда запрашиваем свежие данные (без условного GET) + const rawUrl = String(config.url || ''); + const pathOnly = rawUrl.split('?')[0]; + const isCommunities = pathOnly === '/communities' || pathOnly.endsWith('/communities'); + + if (!isCommunities) { + const key = buildCacheKey(config); + const cached = responseCache.get(key); + if (cached?.etag) { + config.headers = config.headers || {}; + if (!config.headers['If-None-Match']) config.headers['If-None-Match'] = String(cached.etag); + } + } else if (config.headers && config.headers['If-None-Match']) { + // На всякий случай удалим, если был выставлен где-то ещё + delete config.headers['If-None-Match']; } } // Если заголовок не указан, но в теле есть etag — пробуем проставить If-Match