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

Adding documentation for using multiple proxies #3348

Closed
jbranchaud opened this issue Oct 29, 2017 · 5 comments
Closed

Adding documentation for using multiple proxies #3348

jbranchaud opened this issue Oct 29, 2017 · 5 comments

Comments

@jbranchaud
Copy link
Contributor

I noticed in issue #1780 that there was discussion around support for declaring multiple proxies in development. It looks like this was implemented in #1790 and included as part of react-scripts 1.0.0 (#2172).

I'd like to add documentation to the README for this feature, but I'm having trouble figuring out the exact semantics of it. I'm going to continue to investigate how it works. Any pointers in the right direction would be much appreciated.

@jbranchaud
Copy link
Contributor Author

The standard way to proxy a single API is with the string syntax:

// package.json
"proxy": "http://pokeapi.co",

My understanding is that create-react-app (via webpackDevServer) should be able to setup an equivalent proxy using the following syntax:

// package.json
"proxy": {
  "/api": { "target": "http://pokeapi.co" }
},

Unfortunately, I am not able to produce equivalent results. When using the latter syntax, the requests to that API do not get proxied. Instead, they are sent to localhost:3000 from which CRA is being served.

@stale
Copy link

stale bot commented Nov 2, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.

@stale stale bot added the stale label Nov 2, 2018
@Timer Timer closed this as completed Nov 2, 2018
@aeciolevy
Copy link

@jbranchaud is It working? I tried to use in react-scripts 2.0.4 but it did not work.

@crobinson42
Copy link

+1 bump

[email protected] is throwing this and exiting:

When specified, "proxy" in package.json must be a string.
Instead, the type of "proxy" was "object".
Either remove "proxy" from package.json, or make it a string.

@Timer
Copy link
Contributor

Timer commented Dec 7, 2018

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

No branches or pull requests

5 participants