diegomura / react-pdf

📄 Create PDF files using React
https://react-pdf.org
MIT License
14.91k stars 1.18k forks source link

Cors Erorr while using some external images url with Image tag of this library #2863

Open ranausama48 opened 1 month ago

ranausama48 commented 1 month ago

Describe the bug i am using the @react-pdf/renderer to download and view the pdf and the data which is show on @react-pdf/renderer is comes from external APIS and it also contains the img URL I just add the Image Tag of the @react-pdf/renderer but it gives me error (Cors Error ) but this url also working with HTML image tap and direct int he browser

To Reproduce Steps to reproduce the behavior including code snippet (if applies):

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

You can make use of react-pdf REPL to share the snippet

Expected behavior A clear and concise description of what you expected to happen. <Image style={{ width: "100%", height: "50%", }} // src="https://spoonacular.com/recipeImages/604524-556x370.jpg?not-from-cache-please" src={{ uri: "https://spoonacular.com/recipeImages/604524-556x370.jpg?not-from-cache-please", method: "GET", headers: { "Cache-Control": "no-cache" }, body: "", }} />

Screenshots If applicable, add screenshots to help explain your problem.

image

Desktop (please complete the following information):

phoenix19950512 commented 1 month ago

I solved this problem like this. <Image src={`https://corsproxy.io/?url=${encodeURIComponent(imageURL)}`} />