Skip to content
Advertisement

Why is URL.creatObjectURL(blob) giving a cross-origin frame error in NodeJS/React application

I have never had this happen before and am not sure why it’s happening. I have a component written to display PDF files in an iframe as part of a larger application. I am retrieving a BLOB stream from the server and attempting to create a URL for it to display in the iframe but it keeps giving me a cross-origin error, which I thought would not be possible since it is creating the URL out of data.

Here is my entire component:

JavaScript

For completeness here is the GetPDF function from the server which is sending the file.

JavaScript

I have done very little work in node sending files but am positive my client code is good. Where am I going wrong here?

Advertisement

Answer

The problem was that I was trying to be too fancy sending a BLOB or Base64 data. After investigation I rewrote

JavaScript

on the server to

JavaScript

Then calling it from the client using

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement