mars / create-react-app-buildpack

⚛️ Heroku Buildpack for create-react-app: static hosting for React.js web apps
MIT License
3.28k stars 653 forks source link

configuring a proxy #191

Closed perNyfelt closed 3 years ago

perNyfelt commented 3 years ago

The proxy configuration behaves slightly different than the react proxy config in package.json.

In the example configuration i.e.

"proxies": {
    "/api/": {
      "origin": "${API_URL}"
    }
  }

The setting of the API_URL variable is given the example of

heroku config:set API_URL="https://backend.example.com"

This means a url such as /api/login will be https://backend.example.com/login. Most likely the backend url would correspond to what has been tested locally and thus end with /api. If the API_URL instead would be set to

heroku config:set API_URL="https://backend.example.com/api"

Then a call to /api/login would become https://backend.example.com/api/login which is probably more intuitive.

It would be nice to mention this in the readme.md#user-content-proxy

mars commented 3 years ago

This is already documented in Proxy URL config section of the README documentation.