0

I am receiving an error as below - kindly let me know what needs to be done? Access to XMLHttpRequest at 'file:///C:/Usersest1srcdatabase.json' 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.

Bethany
  • 1
  • 3

1 Answers1

0

You probably need to serve your app from a web server, if not already. You can do that via:

  1. http-server
  2. nginx (preferably docker)
  3. Web server for chrome

Could be a duplicate: AngularJS Error: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https

And if you are already serving it from a web server, try reading that file using file reader and not via API call.

Abhijeet Ahuja
  • 5,596
  • 5
  • 42
  • 50