I have made some project which sends XHR request to fetch a locally saved JSON file (the file being in the same folder). I use VS Code with 'live server' extension. The request, response and every thing else works perfectly fine when I open the html file with Live Server. But when I open the file without starting any kind of local server, then the request doesn't return any response and instead logs out an error-
(I am using Chrome)
Access to XMLHttpRequest at 'file:///G:/_PROJECTS/Graph%20Plotter/sample_data.json' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
I searched online about this and found some google documentation but didn't quite understand it. I want to know what the error is about and how can I fix it? Also I would be great help if you could simplify it so that I understand it.
Thanks in advance!