How to override proxy settings via command line with Create React App?

Viewed 392

I set up a React project using Create React App. The development server is configured to proxy API requests via the proxy setting in my package.json:

...
  "proxy": "https://dev-backend.example.com"
...

Is there any possibility to override this settings via command line, environment variable or anything similar? I want to be able to change the proxy address in local development without editing the package.json, because that often leads to accidentally checking in the wrong proxy address into SCM.

What I want to do is something like this to start a development server that proxies to another backend:

$ PROXY=http://localhost:8080 npm start

This GitHub issue is about the same topic, but doesn't propose an easy solution to achieve the desired functionality.

1 Answers
Related