From 97237d85ad7d7624494ce542f0ea17a67b9bb52d Mon Sep 17 00:00:00 2001 From: deonisii Date: Sun, 19 Apr 2026 01:53:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20=D1=81=D0=B2?= =?UTF-8?q?=D1=8F=D0=B7=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5=20=D1=81=20=D0=B8?= =?UTF-8?q?=D0=BD=D1=82=D0=B5=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D0=B5=D0=B9=20?= =?UTF-8?q?=D1=81=20CRM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + app/api/leads/route.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a6d4746..c074bb7 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ ESPOCRM_LEAD_SOURCE=Web Site ``` Их можно положить в локальный `.env` или задать на сервере. +Пример есть в [`.env.example`](.env.example). Установить зависимости: diff --git a/app/api/leads/route.ts b/app/api/leads/route.ts index 44854c6..5f5875c 100644 --- a/app/api/leads/route.ts +++ b/app/api/leads/route.ts @@ -22,9 +22,9 @@ function normalizePhone(input: string) { } export async function POST(request: Request) { - const apiUrl = process.env.ESPOCRM_API_URL; - const apiKey = process.env.ESPOCRM_API_KEY; - const leadSource = process.env.ESPOCRM_LEAD_SOURCE || "Web Site"; + const apiUrl = process.env.ESPOCRM_API_URL?.trim(); + const apiKey = process.env.ESPOCRM_API_KEY?.trim(); + const leadSource = process.env.ESPOCRM_LEAD_SOURCE?.trim() || "Web Site"; if (!apiUrl || !apiKey) { console.error("EspoCRM env is not configured"); @@ -67,7 +67,7 @@ export async function POST(request: Request) { headers: { "Content-Type": "application/json", Accept: "application/json", - "x-api-key": apiKey, + "X-Api-Key": apiKey, }, body: JSON.stringify(payload), cache: "no-store",