From 1b06867d88ad7d6a4a3e584f7f86e5f361f4b8e0 Mon Sep 17 00:00:00 2001 From: Jaronim Pracht Date: Mon, 2 Jun 2025 19:06:25 +0200 Subject: [PATCH] Fix showing pdfs in production Removed redundant PDF.js worker initialization from PDFViewer component and updated the worker source path in main.tsx. Downgraded react-pdf to v8.0.2 to resolve compatibility issues and fixed missing newline in nginx.conf. --- project/docker-compose.yml | 4 ++-- project/frontend/docker/nginx.conf | 2 +- project/frontend/package.json | 2 +- project/frontend/src/components/pdfViewer.tsx | 7 +------ project/frontend/src/main.tsx | 3 +-- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/project/docker-compose.yml b/project/docker-compose.yml index be29228..8892999 100644 --- a/project/docker-compose.yml +++ b/project/docker-compose.yml @@ -19,11 +19,11 @@ services: coordinator: build: context: backend/coordinator - dockerfile: ../../Dockerfile env_file: - .env depends_on: - - db + db: + condition: service_healthy healthcheck: test: wget --spider --no-verbose http://127.0.0.1:5000/health || exit 1 interval: 10s diff --git a/project/frontend/docker/nginx.conf b/project/frontend/docker/nginx.conf index 4bd5b3b..7d028a5 100644 --- a/project/frontend/docker/nginx.conf +++ b/project/frontend/docker/nginx.conf @@ -20,4 +20,4 @@ server { location = /50x.html { root /usr/share/nginx/html; } -} \ No newline at end of file +} diff --git a/project/frontend/package.json b/project/frontend/package.json index c3b04dd..6bb0b68 100644 --- a/project/frontend/package.json +++ b/project/frontend/package.json @@ -26,7 +26,7 @@ "react": "^19.0.0", "react-dom": "^19.0.0", "react-material-file-upload": "^0.0.4", - "react-pdf": "^9.2.1", + "react-pdf": "^8.0.2", "socket.io-client": "^4.8.1" }, "devDependencies": { diff --git a/project/frontend/src/components/pdfViewer.tsx b/project/frontend/src/components/pdfViewer.tsx index 5bb6b96..3c25e13 100644 --- a/project/frontend/src/components/pdfViewer.tsx +++ b/project/frontend/src/components/pdfViewer.tsx @@ -1,16 +1,11 @@ import { useEffect, useRef, useState } from "react"; -import { Document, Page, pdfjs } from "react-pdf"; +import { Document, Page } from "react-pdf"; import "react-pdf/dist/esm/Page/AnnotationLayer.css"; import "react-pdf/dist/esm/Page/TextLayer.css"; import ArrowCircleLeftIcon from "@mui/icons-material/ArrowCircleLeft"; import ArrowCircleRightIcon from "@mui/icons-material/ArrowCircleRight"; import { Box, IconButton } from "@mui/material"; -pdfjs.GlobalWorkerOptions.workerSrc = new URL( - "pdfjs-dist/build/pdf.worker.min.mjs", - import.meta.url, -).toString(); - interface PDFViewerProps { pitchBookId: string; } diff --git a/project/frontend/src/main.tsx b/project/frontend/src/main.tsx index f41d85a..0f5071d 100644 --- a/project/frontend/src/main.tsx +++ b/project/frontend/src/main.tsx @@ -34,9 +34,8 @@ declare module "@tanstack/react-router" { } } -// Initialize PDF.js worker pdfjs.GlobalWorkerOptions.workerSrc = new URL( - "pdfjs-dist/build/pdf.worker.min.mjs", + "pdfjs-dist/build/pdf.worker.min.js", import.meta.url, ).toString();