Dynamic "proxy" attribute configuration in package.json (npm)

  docker, javascript, npm, npm-scripts

On my package.json file, I currently have this config:

"proxy": "http://localhost:5000",

The issue is that I’m adding Docker to this project, so I need that this proxy field is http://localhost:5000 when engineers run the project via npm start, and http://host.docker.internal:5000 when they’re using Docker.

The first thing that came to mind was to add an environment variable, like:

"proxy": "$HTTP_PROXY",

But it’s simply not working, I’m getting this:

When "proxy" is specified in package.json it must start with either http:// or https://

Source: Docker Questions