DEV Community

Discussion on: Deploying a React app with React-Router and an Express Backend

Collapse
 
jharper8393 profile image
James Harper

Hi Nicolas,

Thanks for the article. It seems that when I make the fetch request for the list at ('api/getList') I get a 404 error. It seems that the request is ignoring the proxy and trying to go to 'localhost:300/api/getList' rather than 'localhost:5000/api/getList'.

If I fully define the path in the fetch request ie fetch('localhost:5000/api/getList') then I get an error:
Access to fetch at 'localhost:5000/api/getList' from origin 'localhost:3000' has been blocked by CORS policy: blah blah blah

I understand that one should never really unblock CORS. So my question is, how to I make get requests to my server? And what is the point in the 'proxy' if it does not solve this problem?

Collapse
 
crownedlake profile image
SACHIN CHAND

try adding cors headers if you're facing the cors related problem