Build-A-Quiz-App-With-HTML-CSS-and-JavaScript icon indicating copy to clipboard operation
Build-A-Quiz-App-With-HTML-CSS-and-JavaScript copied to clipboard

Error: Access to fetch at 'file:///Users/questions.json' from origin 'null' has been blocked by CORS policy!

Open AAdewunmi opened this issue 2 years ago • 1 comments
trafficstars

Hi, I'm get this error message when I try to execute fetch. Any ideas for a fix? Thanks

Screenshot 2023-08-10 at 06 55 13

AAdewunmi avatar Aug 10 '23 05:08 AAdewunmi

Its because a html page cannot access file using file:///Users, its done for users security so that websites don't access any other personal / system files

create a http server and run the application on it

Alternatively, you can install python 3

  1. cd into the main project directory
  2. python -m http.server or python3 -m http.server

you will get a message like Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... open that link and you are good to go

adityak1911 avatar Jan 25 '24 20:01 adityak1911