From 423f274c730c076dfe77388a3bb66c11f8ddce8f Mon Sep 17 00:00:00 2001 From: vasya Date: Sat, 11 Apr 2026 22:21:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B2=D1=8B=D0=B2=D0=B5=D0=B4=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87=D0=B8=20csrf=20=D1=82?= =?UTF-8?q?=D0=BE=D0=BA=D0=B5=D0=BD=D0=B0=20=D1=81=20=D1=84=D1=80=D0=BE?= =?UTF-8?q?=D0=BD=D1=82=D0=B0=20=D0=B2=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D0=B9=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82?= =?UTF-8?q?.=20=D0=AF=20=D0=BD=D0=B5=20=D0=BF=D0=BE=D0=BC=D0=BD=D1=8E=20?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=BE=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D1=83=D0=B5=D1=82=D1=81=D1=8F=20=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=BE=D0=BD=20=D0=B3=D0=B4=D0=B5-=D1=82=D0=BE=20=D0=BD=D0=B0?= =?UTF-8?q?=20=D1=82=D0=B5=D0=BA=D1=83=D1=89=D0=B5=D0=BC=20=D1=8D=D1=82?= =?UTF-8?q?=D0=B0=D0=BF=D0=B5,=20=D0=BD=D0=B0=D0=B4=D0=BE=20=D1=81=D0=BC?= =?UTF-8?q?=D0=BE=D1=82=D1=80=D0=B5=D1=82=D1=8C.=20=D0=92=D0=BE=D0=B7?= =?UTF-8?q?=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE,=20=D0=BD=D0=B0=20=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BE=D0=BD=D0=B5=20blade=20=D1=88=D0=B0=D0=B1?= =?UTF-8?q?=D0=BB=D0=BE=D0=BD=D0=B0=20=D0=B8=D0=BB=D0=B8=20=D0=B0=20=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=BE=D0=BD=D0=B5=20tsx=20=D1=81=D0=BA=D1=80?= =?UTF-8?q?=D0=B8=D0=BF=D1=82=D0=BE=D0=B2=20=D0=B2=20=D0=BC=D0=B5=D1=81?= =?UTF-8?q?=D1=82=D0=B5=20=D0=B3=D0=B4=D0=B5=20=D1=84=D0=BE=D1=80=D0=BC?= =?UTF-8?q?=D1=8B=20=D0=BE=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2=D1=8B=D0=B2?= =?UTF-8?q?=D0=B0=D1=8E=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/js/services/getCsrfService.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 resources/js/services/getCsrfService.ts diff --git a/resources/js/services/getCsrfService.ts b/resources/js/services/getCsrfService.ts new file mode 100644 index 0000000..12e160d --- /dev/null +++ b/resources/js/services/getCsrfService.ts @@ -0,0 +1,20 @@ +/** + * Сервис для полуения csrt токена для размещения в формах + * @date 24.07.2025 + * @author dgavrilov + */ + +export const getCsrfToken = ():string => { + const METATAG:HTMLElement|null = document.querySelector('meta[name="csrf-token"]'); + + if (!METATAG) { + return ''; + } + + const CSRFTOKEN:string|null = METATAG.getAttribute('content'); + if (!CSRFTOKEN) { + return ''; + } + + return CSRFTOKEN; +}