Исправил ошибки связанные с интеграцией с CRM
All checks were successful
Auto Deploy / deploy (push) Successful in 16s
All checks were successful
Auto Deploy / deploy (push) Successful in 16s
This commit is contained in:
@@ -43,6 +43,7 @@ ESPOCRM_LEAD_SOURCE=Web Site
|
|||||||
```
|
```
|
||||||
|
|
||||||
Их можно положить в локальный `.env` или задать на сервере.
|
Их можно положить в локальный `.env` или задать на сервере.
|
||||||
|
Пример есть в [`.env.example`](.env.example).
|
||||||
|
|
||||||
Установить зависимости:
|
Установить зависимости:
|
||||||
|
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user