I have been working on a personal project for a while now and during a testing phase for a database, it began reporting that CORS was preventing the file from being fetched, and stopped my testing in its tracks.
The exact error is as follows:
Access to fetch at 'C:\Users\---\Desktop\Test Files\testing.csv' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: chrome, chrome-extension, chrome-untrusted, data, http, https, isolated-app.
Just to be clear, every single file related to this project is held in the same directory and within the same folder on my computer. None of this is running through the web and every resource this project uses can be found in the same file path. I am not running any kind of server for this testing, I am directly opening everything through an HTML fileset into my Google Chrome browser.
To try and fetch the file, I am using the JS fetch() command, as follows:
const response = await fetch('testing.csv');
From what I understand the fetch() command is allowed by the CORS policy, which confuses me why I'm getting this error. Additionally, if these files all have the same origin pathway, why is CORS even getting triggered in the first place? (The 'fetch' portion of my code is no more complex than that single line. Yes I know this could be the issue but i don't understand why, if it is.)
Additional note: I have already tried to use several other solutions. This includes a snippet of JS to clarify filepath and route it through the HTML, as well as several extensions that promised to "bypass" and/or "disable" CORS for websites. These are all solutions I have found through other posts on StackOverflow, and none of them have worked. There is a chance I messed up during implementation, but right now I'm just trying to understand exactly why CORS working this way moreso than I am interested in a solution.