Closed ausaf-a closed 6 months ago
The PDFLoader passes all props to PDF.js when loading the document. That means any of the properties in the DocumentInitParameters
type can also be used as props.
For headers, that means you could do something like this:
const jwtToken = "PUT YOUR JWT TOKEN HERE"
const headers = {
'Authorization': `Bearer ${jwtToken}`,
// Add other headers as needed
};
<PdfLoader url={url} httpHeaders={headers}>
// Your existing code like normal
</PdfLoader>
Hopefully that works 👍!
Works!
I'm retrieving PDFs from my backend. Right now it's working since I have no authentication protecting the /getpdf/{filename} route, but I'm planning on adding it.
How do I get PDFLoader to add headers? I could also just sent the JWT as a query param, but I don't think this is recommended practice.