v1.0.125: Sonnet fix — CORS inside nginx if, raw binary ZIP, multipart fallback
This commit is contained in:
+13
-10
@@ -286,16 +286,19 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
length = int(self.headers.get("Content-Length", 0))
|
length = int(self.headers.get("Content-Length", 0))
|
||||||
body = self.rfile.read(length)
|
body = self.rfile.read(length)
|
||||||
|
|
||||||
# Парсим multipart через email.parser
|
# Raw binary (браузер) или multipart (curl fallback)
|
||||||
msg = BytesParser().parsebytes(
|
if "multipart" in content_type:
|
||||||
b"Content-Type: " + content_type.encode() + b"\r\n\r\n" + body
|
msg = BytesParser().parsebytes(
|
||||||
)
|
b"Content-Type: " + content_type.encode() + b"\r\n\r\n" + body
|
||||||
zip_data = None
|
)
|
||||||
if msg.is_multipart():
|
zip_data = None
|
||||||
for part in msg.get_payload():
|
if msg.is_multipart():
|
||||||
if part.get_filename():
|
for part in msg.get_payload():
|
||||||
zip_data = part.get_payload(decode=True)
|
if part.get_filename():
|
||||||
break
|
zip_data = part.get_payload(decode=True)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
zip_data = body
|
||||||
else:
|
else:
|
||||||
zip_data = body
|
zip_data = body
|
||||||
|
|
||||||
|
|||||||
@@ -44,10 +44,14 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
location /unzip-upload {
|
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-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;
|
proxy_pass http://127.0.0.1:8766;
|
||||||
client_max_body_size 100m;
|
client_max_body_size 100m;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="topbar">
|
<div class="topbar">
|
||||||
<img src="/nubes-logo.svg" alt="Nubes">
|
<img src="/nubes-logo.svg" alt="Nubes">
|
||||||
<span class="title">Сверка договоров — LLM AI-driven Event Sourcing <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.124 — Lucee</span></span>
|
<span class="title">Сверка договоров — LLM AI-driven Event Sourcing <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.125 — Lucee</span></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
@@ -259,9 +259,11 @@ fileInput.addEventListener('change', async function() {
|
|||||||
renderTable();
|
renderTable();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var fd = new FormData();
|
var zipResp = await fetch(UNZIP_URL, {
|
||||||
fd.append('file', f);
|
method: 'POST',
|
||||||
var zipResp = await fetch(UNZIP_URL, { method: 'POST', body: fd });
|
body: f,
|
||||||
|
headers: {'Content-Type': 'application/zip'}
|
||||||
|
});
|
||||||
var zipData = await zipResp.json();
|
var zipData = await zipResp.json();
|
||||||
if (!zipData.ok || !zipData.files) throw new Error('unzip failed');
|
if (!zipData.ok || !zipData.files) throw new Error('unzip failed');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user