react-doc-viewer stuck in loop making get requests to blob url or endpoint url for non-MS files
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.
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 ?
same here, did you ever figure this out?