Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 8 commits into from

Conversation

yuanalexwu
Copy link

@yuanalexwu yuanalexwu commented Oct 31, 2017

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

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@yuanalexwu yuanalexwu changed the title Add default option for both String and Object proxy in package.json Add default behavior for both String and Object proxy option in package.json Oct 31, 2017
@gaearon
Copy link
Contributor

gaearon commented Oct 31, 2017

Sorry, I messed up git history. Would you mind doing

git fetch origin

Then write down hashes of your commits, do git reset --hard origin/master and cherry-pick them back onto your branch.

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@gaearon
Copy link
Contributor

gaearon commented Jan 9, 2018

Can I ask you to propose these changes in #3366 and see if you can get a consensus? It's hard for me to navigate these issues, and people ask for different things about the proxy behavior. I'd like to get proxy users together so they can discuss what they need it to do.

@gaearon gaearon closed this Jan 9, 2018
@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants