Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error: Not allowed to load local resource #1900

Open
4 tasks done
LockeandDropit opened this issue Oct 15, 2024 · 1 comment
Open
4 tasks done

Error: Not allowed to load local resource #1900

LockeandDropit opened this issue Oct 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@LockeandDropit
Copy link

LockeandDropit commented Oct 15, 2024

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

I am unable to load a firestore URL as the source of the pdf viewer when in production mode. I get the error "Not allowed to load local resource" despite the resource being from cloud storage.

Steps to reproduce

const [resume, setResume] = useState(null)

const uploadToFirebase = async (x) => {

const storage = getStorage();
const resumeRef = ref(storage, "users/" + user.uid + "/resume.pdf");

const file = x;
await uploadBytes(resumeRef, file).then((snapshot) => {
  console.log("good to go")
})
.catch((e) => {
  console.log(e)
})

};

const downloadURL = async () => {
await getDownloadURL(resumeRef).then((response) => {
setResume(response);
})
.catch((error) => {
});
});
}

return (
<>
<PDFViewer src={resume ? resume : null} />
</>
)

Expected behavior

I expected the Document component to be able to render the pdf when given the URL.

Actual behavior

The Document component gave an error "Failed to load PDF file", with a console error stating "Error: Not allowed to load local resource".

Additional information

No response

Environment

  • Browser (if applicable): Brave v1.70.123
  • React-PDF version: ^9.1.0
  • React version: 18.2.0
  • Bundler name and version (if applicable):
@LockeandDropit LockeandDropit added the bug Something isn't working label Oct 15, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants
@LockeandDropit and others