john-smilga / react-projects

4.77k stars 3.86k forks source link

Fix CORS permissions to allow the projects to work from new domain #118

Open bizmate opened 2 weeks ago

bizmate commented 2 weeks ago

As per lines

Currently the domain does not allow CORS requests as shown here

Access to fetch at 'https://course-api.com/react-tours-project' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. The alternative is to curl the file and serve it from the local public folder

curl -o 02-tours/setup/public/tours.json https://www.course-api.com/react-tours-project and change the url to const url = 'http://localhost:3000/tours.json'

or for the server owner to allow CORS

TorasFerdin commented 2 weeks ago

I had the same issue but, thankfully, i managed to resolve it thanks to your curl fix, thank you! I hope this will get fixed for good.