Fix Nginx 413 error for PDF uploads and html2canvas hidden styling

This commit is contained in:
2026-09-23 12:18:15 +05:30
parent 0b99b3a214
commit 6b1c83444e
3 changed files with 12 additions and 4 deletions
+1
View File
@@ -1,6 +1,7 @@
server { server {
listen 80; listen 80;
server_name localhost; server_name localhost;
client_max_body_size 50M;
location /api/ { location /api/ {
proxy_pass http://limelite-api:5000; proxy_pass http://limelite-api:5000;
+11 -4
View File
@@ -216,7 +216,6 @@ const AnalysisResultPage = () => {
let generatedPdfLink = verificationLink; let generatedPdfLink = verificationLink;
if (reportRef.current) { if (reportRef.current) {
const reportElement = reportRef.current; const reportElement = reportRef.current;
reportElement.style.display = 'block';
try { try {
const canvas = await html2canvas(reportElement, { const canvas = await html2canvas(reportElement, {
@@ -241,15 +240,21 @@ const AnalysisResultPage = () => {
method: 'POST', method: 'POST',
body: fd body: fd
}); });
if (!saveRes.ok) {
throw new Error(`Server returned ${saveRes.status} for PDF upload`);
}
const saveData = await saveRes.json(); const saveData = await saveRes.json();
if (saveData.success) { if (saveData.success) {
generatedPdfLink = `${API_BASE_URL}${saveData.link}`; generatedPdfLink = `${API_BASE_URL}${saveData.link}`;
} else {
console.error("Backend failed to save PDF:", saveData);
} }
} catch(err) { } catch(err) {
console.error("Failed to generate/upload PDF during save:", err); console.error("Failed to generate/upload PDF during save:", err);
} finally { alert("PDF Generation/Upload Error: " + err.message);
reportElement.style.display = 'none';
} }
} }
@@ -860,7 +865,9 @@ const AnalysisResultPage = () => {
<div <div
ref={reportRef} ref={reportRef}
style={{ style={{
display: 'none', position: 'absolute',
top: '-9999px',
left: '-9999px',
width: '210mm', width: '210mm',
minHeight: '297mm', minHeight: '297mm',
backgroundColor: '#ffffff', backgroundColor: '#ffffff',
BIN
View File
Binary file not shown.