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
  • Merge requests
  • !3204

Set proxy setting via environmental variable

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/maxhallinan/proxy-env-var into master Sep 27, 2017
  • Overview 12
  • Commits 1
  • Pipelines 0
  • Changes 1

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.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/maxhallinan/proxy-env-var