DEV Community

Discussion on: Deploying Create-React-App with Json-Server as backend to Github

Collapse
artemkolinko profile image
Artem Kolinko

Hi, thanks for article!

I've made a request to my-json-server.typicode.com// from my app by fetch() and get CORS error.

How I can resolve it?

Collapse
fbolaji profile image
Francis.B

Set your fetch() headers
'Access-Control-Allow-Origin': '*',
Accept: 'application/json;odata.metadata=full',
'Content-Type': 'application/json',

Collapse
nikita_guliaev profile image
Nikita Guliaev🧩 Author

Hi Artem, you can do it by setting headers. This article should help: medium.com/@dtkatz/3-ways-to-fix-t...