react-doc-viewer icon indicating copy to clipboard operation
react-doc-viewer copied to clipboard

Displayes error for every file: An error occurred

Open supinder-cf opened this issue 3 years ago • 12 comments

An error occurred We're sorry, but for some reason we can't open this for you.

It doesn't work with the demo files which are included in the project. image

Node version: 16 "dependencies": { "@cyntler/react-doc-viewer": "^1.2.0", "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^13.3.0", "@testing-library/user-event": "^13.5.0", "@types/jest": "^27.5.2", "@types/node": "^16.11.41", "@types/react": "^18.0.14", "@types/react-dom": "^18.0.5", "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "5.0.1", "typescript": "^4.7.4", "web-vitals": "^2.1.4" },

supinder-cf avatar Jun 28 '22 13:06 supinder-cf

I have the same problem, Can someone help us?

Screen Shot 2022-06-28 at 22 52 09

aaron-0406 avatar Jun 29 '22 03:06 aaron-0406

@supinder-cf @aaron-0406 Have you xlsx file/files by external url or by import/require locally? Can I get the file/files? Maybe I would be able to reproduce and fix it.

cyntler avatar Jun 29 '22 20:06 cyntler

@cyntler thanks for responding back. Please find the attached files that I am trying. I am requiring these files locally. Here is the code for the same.

import React from 'react';
import DocViewer, { DocViewerRenderers } from "@cyntler/react-doc-viewer";
import './App.css';

const App = () => {
  const docs = [
    { uri: require("./test-excelaki.xlsx") },
    { uri: require("./test-doc.docx") }
  ];

  return (
    <div className="App" >
      <DocViewer pluginRenderers={DocViewerRenderers} documents={docs} />
    </div>
  );
}

export default App;

test-doc.docx test-excelaki.xlsx

supinder-cf avatar Jun 29 '22 23:06 supinder-cf

This may shed a little light into it...it appears that the issue may have to do with Tracking Prevention. Seems to happen on Word docs when trying to pull down data from Microsoft's servers. image

rnwalker7 avatar Jul 11 '22 02:07 rnwalker7

@supinder-cf @rnwalker7 The problem is probably because this library is using "Office Web Viewer" by Microsoft and it requires public available URL to the file. Localhost is not public. But after all, that's my guess and I'm not sure. I have to check this problem yet.

cyntler avatar Jul 11 '22 08:07 cyntler

@cyntler Good point. I'm looking at workarounds as well, but may need to push to remote for testing purposes.

rnwalker7 avatar Jul 11 '22 11:07 rnwalker7

So I just thought of something...I'm wondering if the distant end requires CORS and throws the error if the web server doesn't return a CORS header. I'll investigate.

rnwalker7 avatar Aug 02 '22 17:08 rnwalker7

So I just thought of something...I'm wondering if the distant end requires CORS and throws the error if the web server doesn't return a CORS header. I tried checking that by running chrome without CORS and it doesn't appear to be the case here (at least not for me). Also clicking on the learn more link generates a 404 error

ironcracker avatar Aug 31 '22 09:08 ironcracker

how can i make the local file as public , I am facing the same problem

ibrahimalkatip avatar Sep 12 '23 05:09 ibrahimalkatip

I also have the same problem

devScripts.js:6523 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function. at LoadingTimeout (http://localhost:8000/mf-dep_vendors-node_modules_cyntler_react-doc-viewer_dist_esm_index_js-node_modules_react-is_index_js.945e8de5.async.js:218:23) at Contents image

image

qidasheng369 avatar Nov 17 '23 03:11 qidasheng369

@cyntler https://static-sq-chat.s3.amazonaws.com/uploads/98820cea/D_Strange-Girl_Meets_Boy_Penguin_Readers-1-min.pdf?AWSAccessKeyId=adghakdehaoyKLKHSnKLhljKLDHklabdx&Signature=fsdfDsfsfsfsfsfD&Expires=1704870237
<DocViewer documents={[{uri:'/movies100.pdf'}]} pluginRenderers={DocViewerRenderers} prefetchMethod="GET" /> Iam not able to load from the above path but files from local are working fine

SidWML avatar Jan 10 '24 06:01 SidWML

The react-doc-viewer uses Office Web Apps viewer. However, when it attempt to use signed URLs from Amazon S3, it fails because these URLs contain tokens as query parameters. This issue causes the Office viewer to not work properly. To overcome this, you can mask the original link and pass the masked link as the URI to react-doc-viewer. refer below stackoverflow link: https://stackoverflow.com/questions/59798131/amazon-s3-signed-url-is-not-working-with-office-web-apps-viewer-encodeuricompon

SatamSai avatar Feb 20 '24 18:02 SatamSai