Closed yoavke closed 3 years ago
If this works locally, but not running on Heroku, then you have a difference between those environments. Probably PUBLIC_URL
is not working the way you expect it too, and by luck, it happens to work locally.
See the create-react-app docs for how that configuration is intended to be used: https://create-react-app.dev/docs/using-the-public-folder/
Specifically, see the usage syntax is different than your sample in this issue's description:
%PUBLIC_URL%/favicon.ico
Revision: I see that further down in those directions, that your usage is correct for within javascript.
I closed this because it is not a problem with Heroku deployment. To find a solution, continue to research the issue from the create-react-app standpoint.
Trying to load images you get as a component prop
<img src={process.env.PUBLIC_URL} + '/' + props.img} />
Doesn't work in Heroku. Image address will lead to the same page. your-app.herokuapp.com/myImages/myImage.png - loads the page, not the image.
Building locally using CRA build works as expected.