0

I am trying to create an anchor tag that will link to a PDF asset in my contentful space, so when the user clicks on the link it will download to their computer.

However, because the asset url is not of the same origin, the PDF will just open up within the browser itself.

Here is the current structure of the markup:

<a
  download="test.pdf"
  href="//assets.ctfassets.net/[contentfulID]/[contentfulID]/[contentfulID]]/test.pdf"
>
  <span>Download</span>
</a>

The problem as I mentioned earlier is that the asset url will not be of the same origin. Is there anyway to get around this problem?

cyanbird
  • 13
  • 3
  • Does this answer your question? [How to download PDF automatically using js?](https://stackoverflow.com/questions/34691525/how-to-download-pdf-automatically-using-js) – Naren Sep 24 '21 at 16:02
  • @Naren Unfortunately I don't believe so as this doesn't address the issue of cross-origin downloads. – cyanbird Sep 24 '21 at 16:36
  • this seems to work for me: https://stackoverflow.com/questions/49474775/chrome-65-blocks-cross-origin-a-download-client-side-workaround-to-force-down – thchp Oct 04 '21 at 06:45

0 Answers0