How Do I Avoid CORS Errors with View SDK?
I am trying to run the embed viewer script on my desktop, as it states in the sample that you don't even need credentials to test the viewer. I have entered my credentials anyway, because I keep getting a CORS error. The pdf viewer does appear to be embedded in the browser, but my pdf file which is stored in a folder called "news" on my website does not appear in the viewer. The error message says: "File preview not available, please reload to try again." In the web developer console it shows the error is related to CORS. I cannot find an easy explanation to correct this error, so I appreciate any help with this problem. Here is my test code:
<html>
<head>
<title>Test 2</title>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
</head>
<body>
<div id="adobe-dc-view"></div>
<script type="text/javascript">
document.addEventListener("adobe_dc_view_sdk.ready", function()
{
var adobeDCView = new AdobeDC.View({clientId: "<redacted>", divId: "adobe-dc-view"});
adobeDCView.previewFile(
{
content: {location: {url: "https://<URL redacted>/2020/news/Newsletter_050420.pdf"}},
downloadWithCredentials: true,
metaData: {fileName: "Newsletter_050420.pdf"}
});
});
</script>
</body>
</html>