Allow Proxy to be set by environment variables
Created by: dan-valentine
Is your proposal related to a problem?
Currently, we are using the proxy for create-react-app to proxy requests to a staging server and it works great. We have several environments hosted for development and production (e.g. staging, testing, prod, BSEs, and occasionally long-lived feature branches). If we want to change what server we are proxying to we need to change the field in package.json and remember to revert this change before committing. This frustrates me because I very frequently forget and commit this change.
Describe the solution you'd like
I'd like to be able to set the proxy via environment variables so that it is configurable without having to change tracked files. This would allow us to add environment variables in the shell and not have to change tracked files to change the proxy. I'd like to append || proccess.env.PROXY
to line 111 of react-scripts/scripts/start.js
Describe alternatives you've considered
We looked into using 'http-proxy-middleware' to setup a custom proxy that will proxy off environment variables. We are currently not prefixing our endpoints and setting up 'http-proxy-middleware' for a custom proxy to work on environment variables would require some refactoring of the application and how we are integrating with third party software we are using for authorization and processing payments.
Additional context
(Write your answer here.)