From 4f66853447d8f54168400c1d04ae0a6dc1481a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Tue, 23 Jun 2026 08:36:42 +0400 Subject: [PATCH] =?UTF-8?q?v1.0.125:=20Sonnet=20fix=20=E2=80=94=20CORS=20i?= =?UTF-8?q?nside=20nginx=20if,=20raw=20binary=20ZIP,=20multipart=20fallbac?= =?UTF-8?q?k?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/convert_server.py | 23 +++++++++++++---------- deploy/nginx-contracts.conf | 10 +++++++--- index.cfm | 10 ++++++---- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/deploy/convert_server.py b/deploy/convert_server.py index 261cb4f..399d404 100755 --- a/deploy/convert_server.py +++ b/deploy/convert_server.py @@ -286,16 +286,19 @@ class Handler(BaseHTTPRequestHandler): length = int(self.headers.get("Content-Length", 0)) body = self.rfile.read(length) - # Парсим multipart через email.parser - msg = BytesParser().parsebytes( - b"Content-Type: " + content_type.encode() + b"\r\n\r\n" + body - ) - zip_data = None - if msg.is_multipart(): - for part in msg.get_payload(): - if part.get_filename(): - zip_data = part.get_payload(decode=True) - break + # Raw binary (браузер) или multipart (curl fallback) + if "multipart" in content_type: + msg = BytesParser().parsebytes( + b"Content-Type: " + content_type.encode() + b"\r\n\r\n" + body + ) + zip_data = None + if msg.is_multipart(): + for part in msg.get_payload(): + if part.get_filename(): + zip_data = part.get_payload(decode=True) + break + else: + zip_data = body else: zip_data = body diff --git a/deploy/nginx-contracts.conf b/deploy/nginx-contracts.conf index 99291b1..a649610 100644 --- a/deploy/nginx-contracts.conf +++ b/deploy/nginx-contracts.conf @@ -44,10 +44,14 @@ server { } location /unzip-upload { + if ($request_method = OPTIONS) { + add_header Access-Control-Allow-Origin "*"; + add_header Access-Control-Allow-Methods "POST, OPTIONS"; + add_header Access-Control-Allow-Headers "*"; + add_header Content-Length 0; + return 204; + } add_header Access-Control-Allow-Origin "*"; - add_header Access-Control-Allow-Methods "POST, OPTIONS"; - add_header Access-Control-Allow-Headers "*"; - if ($request_method = OPTIONS) { return 200; } proxy_pass http://127.0.0.1:8766; client_max_body_size 100m; } diff --git a/index.cfm b/index.cfm index 2a6426e..7854055 100644 --- a/index.cfm +++ b/index.cfm @@ -75,7 +75,7 @@
Nubes - Сверка договоров — LLM AI-driven Event Sourcing v1.0.124 — Lucee + Сверка договоров — LLM AI-driven Event Sourcing v1.0.125 — Lucee
@@ -259,9 +259,11 @@ fileInput.addEventListener('change', async function() { renderTable(); try { - var fd = new FormData(); - fd.append('file', f); - var zipResp = await fetch(UNZIP_URL, { method: 'POST', body: fd }); + var zipResp = await fetch(UNZIP_URL, { + method: 'POST', + body: f, + headers: {'Content-Type': 'application/zip'} + }); var zipData = await zipResp.json(); if (!zipData.ok || !zipData.files) throw new Error('unzip failed');