Angular- Cors issue

Angular- Cors issue
0

Hi
I’m using Angular 8 and the the ability to download a zip file from network path fails on a CORS related issue

I’m getting the following error message: “Access to XMLHttpRequest at ‘file://IPAddress/d$/***/Output.zip’ from origin ‘http://localhost:4200’’ has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.”

Here is the function which I’m using to download the zip file:

downloadFile(filePath: string) {
    return this.http.get(filePath, {
      responseType: 'arraybuffer'
    }).subscribe(data => {
      const blob = new Blob([data], {
        type: 'application/zip'
      });
      const url = window.URL.createObjectURL(blob);
      window.open(url);
    });
  }

I already spend much time on it.
Can you please assist?

Best Regards,
Nadeem Bader

Http client expects http:// protocol, not file://. To make it work you need to place the file to assets folder.

Hi
Thank you very much for your reply, but in my case all files are located in a shared folder that I can’t move into the assets folder.
Any suggestions?
Best Regards,
Nadeem Bader