Created by: maxhallinan
This enables the development server proxy setting to be configured via a PROXY
environmental variable.
My team is working on a CRA-based app. Each of us runs the API server in a virtual machine and the IPs of these virtual machines are not necessarily the same. For reasons beyond our control, we're unable to configure this server to set CORS headers. For that reason, we depend on the proxy
setting in package.json
to work around CORS. Because that setting is committed to the repo, we've all had to set the same hostname for our virtual machines in our local /etc/hosts
. This isn't a huge problem but it feels like polluting the repo with an environmental artifact. Like the PORT
setting, it would be nicer to set the proxy target via the environment.
I'm guessing that this setting lives in package.json
because it's optionally a JSON blob. If this is the case, perhaps it's better to move this out of package.json
entirely and into something like proxy.json
. Then this file could be git-ignored.
I appreciate create-react-app's goal to keep configuration to a minimum. My aim here is not to increase configurability but to move environmental-specific configuration to a less cross-environment location.