Reputation: 5526
Mine react apps fetch requests work fine when I test in dev
environment (npm start
) but after creating a build package (npm run build
) and then running that, all my fetch requests receive a failed status when making requests to my locally hosted API. Could this be because my API is not https
? Any other ideas?
Thanks
Upvotes: 1
Views: 1087
Reputation: 40
Try adding a proxy
field in the package.json of your react app. Once that is in place, run build and test. This usually solves the api issue that react can have with api.
package.json: proxy: "http://localhost:8000"
requests in React app: fetch('/api/urls/....')
Upvotes: 0
Reputation: 902
Double check if you have the REACT_APP_API_URL
on your .env files:
Upvotes: 0