React app is looking for static files in different location when using proxy

Building for relative paths for create-react-app

There can be two places where you could define relative path

1) By default, Create React App produces a build assuming your app is hosted at the server root. To override this, specify the homepage in your package.json, for example:

  "homepage": "http://mywebsite.com/react_app",

This will let Create React App correctly infer the root path to use in the generated HTML file.

2) If you are using react-router@^4, relative path can be set using basename

<Router history={browserHistory} basename={'react_app'}>
  <Route path="/" component={App} />
</Router>

Hope that helps!!!


where did you store assets? If it is not the public folder, I think you should take a look at https://create-react-app.dev/docs/using-the-public-folder


You have to add base tag(URL):

<html>
<head>
   <base href="./react_app" target="_blank" />
</head>
...
</html>

Some useful references on this - https://facebook.github.io/create-react-app/docs/deployment#building-for-relative-paths and the PUBLIC_URL https://facebook.github.io/create-react-app/docs/advanced-configuration.