cyntler / cyntler/react-doc-viewer

react-doc-viewer stuck in loop making get requests to blob url or endpoint url for non-MS files

Open
#139 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
481
Forks
147
PR merge metrics
No merged PRs in 30d

Description

When I try to load files that are not Microsoft documents, I tried grabbing the file and then generating a blob which is passed to react-doc-viewer as a uri. It seems to be throwing the library in a loop of get requests as shown in the screenshot below. Eventually the tab crashes.

![Capture](https://github.com/cyntler/react-doc-viewer/assets/47833530/0a5fbf55-6651-44fc-b459-09b405f62ae0)

Even if I try to just pass the secure endpoint URL to access the file, it behaves similarly and gets stuck making GET requests. If I pass an unsecure URL to publicly access the file, it works but the files are private and not meant to be publicly accessible.

Here's the function that grabs the file and returns a blob url
`
export const LoadFile = async (url) => {
const options = {
method: 'GET',
};

const response = await fetch(url, options);

if (response.status !== 200 && response.status !== 304) {
return '';
}

const data = await response.blob();

const fileURL = URL.createObjectURL(data);

return fileURL;
};
`

This is then passed to the doc viewer as:
`
[
{
"uri": "blob:https://camfm.dev.streamdata.com/dbebf757-6efc-4d21-986f-98a2ca330155",
"name": "file.pdf"
}
]
`

Am I doing something wrong here or is it an issue with the library ?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.