Giter Club home page Giter Club logo

Comments (9)

arnonrdp avatar arnonrdp commented on July 2, 2024 1

I am facing the exactly same problem right now.
@mask2012 @dkruchok did you solved this, guys?

from dom-to-image-more.

emrecoban avatar emrecoban commented on July 2, 2024 1

This is a significant issue. There is no need to access the data source within the DOM again. However, you can resolve this issue by using a third-party URL or by setting up your own API server.

Solution

While there is no guaranteed solution, the problem can be resolved by using allOrigins. With allOrigins, you can bypass CORS policies and access the base64 version of the image, allowing the image in the DOM tree to be displayed.

Using allOrigins is simple (fetch or axios doesn't matter):
const base64 = await axios.get(https://api.allorigins.win/get?url=${yourImageURL})

Sample Repository

from dom-to-image-more.

IDisposable avatar IDisposable commented on July 2, 2024 1

That's a really interesting solution, might be able to add an option to pipe all image requests through that automatically (opt-in). Will look into that idea after I do my taxes :)

from dom-to-image-more.

mask2012 avatar mask2012 commented on July 2, 2024

I have the same problem, and what even funny is, the same url, my computer always works fine, and other's always CORS.
Anyone have clue with this?

from dom-to-image-more.

mask2012 avatar mask2012 commented on July 2, 2024

the first pic is the wrong one, and the second is on my computer, which is always fine.
image
image

from dom-to-image-more.

tarcisioaraujo avatar tarcisioaraujo commented on July 2, 2024

I have the same problem, has anyone found a solution? Should I implement a proxy server and put requests through it?

from dom-to-image-more.

udayraj713 avatar udayraj713 commented on July 2, 2024

Try cacheBust: true

domtoimage.toPng(nodeName, { cacheBust: true })

from dom-to-image-more.

tarcisioaraujo avatar tarcisioaraujo commented on July 2, 2024

Try cacheBust: true

domtoimage.toPng(nodeName, { cacheBust: true })

Don't work in all cases

from dom-to-image-more.

emrecoban avatar emrecoban commented on July 2, 2024

That's a really interesting solution, might be able to add an option to pipe all image requests through that automatically (opt-in). Will look into that idea after I do my taxes :)

Actually considered the same solution until I noticed the delay caused by image loading :) Therefore, using a third-party URL and rendering all images may not be efficient. In fact, frameworks with server-side functions like Next.js make it quite easy and eliminate the need for this.

It seems like many people are encountering the same issue. With your permission, I would like to add a comment about this topic in the readme file.

from dom-to-image-more.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.