Skip to content

Commit

Permalink
fix(island-ui): Update url for pdf worker - hotfix (#16274)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
thordurhhh and kodiakhq[bot] authored Oct 4, 2024
1 parent 19453cb commit d62e8bc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libs/island-ui/core/src/lib/PdfViewer/PdfViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ export const PdfViewer: FC<React.PropsWithChildren<PdfViewerProps>> = ({
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) => {
Expand Down

0 comments on commit d62e8bc

Please sign in to comment.