Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #12420
Closed
Open
Issue created May 21, 2022 by Administrator@rootContributor

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.)

Assignee
Assign to
Time tracking