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
  • !3369

Add default behavior for both String and Object proxy option in package.json

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/yuanalexwu/master into master Oct 31, 2017
  • Overview 4
  • Commits 8
  • Pipelines 0
  • Changes 2

Created by: yuanalexwu

When we fetching data from another origin we should use proxy. Normally, we set proxy option as String in pakcage.json:

{
  "proxy": "http://abc.com"
}

It works as expected.

But, if we have several apis that are cross origin.Then we should set proxy option as an Object:

{
  "proxy": {
    "/api/foo": {
      "target": "http://abc.com" 
     },
    "/api/bar": {
      "target": "http://def.com" 
     },
   }
}

It doesn't work because of the proxy request header's host does not change the origin to the target.So we still get cross origin error

We can fix it as below:

{
  "proxy": {
    "/api/foo": {
      "target": "http://abc.com" ,
      "changeOrigin": true
     },
    "/api/bar": {
      "target": "http://def.com",
      "changeOrigin": true
     },
   }
}

I think it should be a default behavior both in String and Object proxy option

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/yuanalexwu/master