From d62e8bcf0f3cba2ee9d8d43144ab48ee5cfc2d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20H?= Date: Fri, 4 Oct 2024 16:53:22 +0000 Subject: [PATCH] fix(island-ui): Update url for pdf worker - hotfix (#16274) * fix(island-ui): Update url for pdf worker (#16273) * fix(island-ui): pdf viewer worker url (#16280) * Update url * Update url * Update url --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- libs/island-ui/core/src/lib/PdfViewer/PdfViewer.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/island-ui/core/src/lib/PdfViewer/PdfViewer.tsx b/libs/island-ui/core/src/lib/PdfViewer/PdfViewer.tsx index 641aab7dff71..294b59e435c7 100644 --- a/libs/island-ui/core/src/lib/PdfViewer/PdfViewer.tsx +++ b/libs/island-ui/core/src/lib/PdfViewer/PdfViewer.tsx @@ -45,7 +45,12 @@ export const PdfViewer: FC> = ({ useEffect(() => { import('react-pdf') .then((pdf) => { - pdf.pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdf.pdfjs.version}/pdf.worker.min.mjs` + const path = window.location.origin + const isLocalhost = path.includes('localhost') + const workerUrl = isLocalhost + ? 'https://assets.ctfassets.net/8k0h54kbe6bj/8dqL0H07pYWZEkXwLtgBp/1c347f9a4f2bb255f78389b42cf40b97/pdf.worker.min.mjs' + : `${path}/assets/pdf.worker.min.mjs` + pdf.pdfjs.GlobalWorkerOptions.workerSrc = workerUrl setPdfLib(pdf) }) .catch((e) => {