1

I'm using vue-pdf for pdf-viewer. but I have got this error.

this is my code

<template>
...
<pdf :src="pdfUrl" />
...
</template>

<script>
...
import pdf from 'vue-pdf'

export default {
  ...
  components: {
   ...,
   pdf
  }
  data() {
    return ({
      pdfUrl: "...",
      ....
    })
  }
}
</script>

this is error image enter image description here

please help me.

Boris
  • 179
  • 1
  • 10
  • 2
    You don't need SO's help: the error literally tells you what's wrong, and google will be more than happy to help you: make your server send CSP headers to allow `eval`. Something you _never_ want to allow, but go for it if you _really_ need this functionality client-side rather than building PDFs server side and having users download those, instead. – Mike 'Pomax' Kamermans Jul 23 '21 at 03:14
  • Could you explain more details? what's the solution? – Boris Jul 23 '21 at 03:17
  • I'm not sure what is wrong. Please help me. – Boris Jul 23 '21 at 03:18
  • 1
    So google for your error: CSP is a thing you need to know about when you're hosting content on any server on the modern internet, read up on it. Start on MDN: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP – Mike 'Pomax' Kamermans Jul 23 '21 at 03:37
  • I got it. Thanks for your help. but I don't know how to use it in my case. Please explain. – Boris Jul 23 '21 at 03:44
  • 1
    No: you can read, so you can read up on what `unsafe-eval` means for script CSP. You don't need SO's help here: there are plenty of resources that explain this on the internet already. – Mike 'Pomax' Kamermans Jul 23 '21 at 03:50
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/235201/discussion-between-boris-and-mike-pomax-kamermans). – Boris Jul 23 '21 at 03:54
  • @Boris The recommendation with unsafe-eval makes sense but it can indicate underlying problem. Make sure you use the latest vue-pdf version. The problem is specific to pdfjs lib and it seems it has been solved some time ago. – Estus Flask Jul 23 '21 at 04:00
  • I have installed latest vue-pdf version `4.3.0`. – Boris Jul 23 '21 at 05:12
  • but can't solve this problem. – Boris Jul 23 '21 at 06:00

0 Answers0