Исправил ошибки связанные с интеграцией с CRM
All checks were successful
Auto Deploy / deploy (push) Successful in 16s

This commit is contained in:
deonisii
2026-04-19 01:53:02 +03:00
parent 97b996edc8
commit 97237d85ad
2 changed files with 5 additions and 4 deletions

View File

@@ -43,6 +43,7 @@ ESPOCRM_LEAD_SOURCE=Web Site
``` ```
Их можно положить в локальный `.env` или задать на сервере. Их можно положить в локальный `.env` или задать на сервере.
Пример есть в [`.env.example`](.env.example).
Установить зависимости: Установить зависимости:

View File

@@ -22,9 +22,9 @@ function normalizePhone(input: string) {
} }
export async function POST(request: Request) { export async function POST(request: Request) {
const apiUrl = process.env.ESPOCRM_API_URL; const apiUrl = process.env.ESPOCRM_API_URL?.trim();
const apiKey = process.env.ESPOCRM_API_KEY; const apiKey = process.env.ESPOCRM_API_KEY?.trim();
const leadSource = process.env.ESPOCRM_LEAD_SOURCE || "Web Site"; const leadSource = process.env.ESPOCRM_LEAD_SOURCE?.trim() || "Web Site";
if (!apiUrl || !apiKey) { if (!apiUrl || !apiKey) {
console.error("EspoCRM env is not configured"); console.error("EspoCRM env is not configured");
@@ -67,7 +67,7 @@ export async function POST(request: Request) {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
Accept: "application/json", Accept: "application/json",
"x-api-key": apiKey, "X-Api-Key": apiKey,
}, },
body: JSON.stringify(payload), body: JSON.stringify(payload),
cache: "no-store", cache: "no-store",