Basic-MERN-Stack-App
Basic-MERN-Stack-App copied to clipboard
Faced issues with API calls during Development
To tell the React development server to proxy any unknown requests to your node API server in development, you can add a proxy field to your client package.json, for example:
"proxy": "http://localhost:5000"
which will redirect all traffic to node API and not REACT Development URL.
This way, when you fetch('/api/articles') in development, the development server will recognize that it’s not a static asset, and will proxy your request to http://localhost:5000/api/articles as a fallback.
You might face a challenge using http:// instead of https://. Not adding the s to it might cause a problem when calling API.
I did try the proxy option then but was not working for me. But works in my new projects. I am happy to assign this issue to you if you are interested to solve :grinning:
Yes thank-you, i will be happy to.
@ogeobubu Still got the same error.
Proxy
error: Could not proxy request /favicon.ico from localhost:3000 to http://localhost:5000.`