Skip to content

Adding documentation for using multiple proxies #3348

Description

@jbranchaud

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.

Activity

  1. jbranchaud commented on Oct 29, 2017

    @jbranchaud
    ContributorAuthor

    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.

  2. stale commented on Nov 2, 2018

    @stale

    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.

  3. aeciolevy commented on Nov 11, 2018

    @aeciolevy

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

  4. crobinson42 commented on Dec 5, 2018

    @crobinson42

    +1 bump

    react-scripts@2.1 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.
    
  5. locked and limited conversation to collaborators on Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions