create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Proxy feature in package.json

Open aaronplanell opened this issue 9 years ago • 2 comments

Can you reproduce the problem with latest npm?

Yes, I'm using the last stable npm version. stable -> 6.9 (-> v6.9.1) (default)

Can you still reproduce it? I updated and I reproduced the issue.

Description

I'm using the proxy configuration and it seems it doesn't work.

Expected behavior

I'm calling an API REST. I configured the package.json with: "proxy": "http://10.116.12.170:8080", but doesn't work.

Actual behavior

I have this action:

function fetchMetadades(dispatch) {
  return dispatch => {
    dispatch(requestMetadades())
    return fetch(`/vars/metadades`)
      .then(response => response.json())
      .then(json => dispatch(receiveMetadades(json)))
  }
}

and the response.url must have http://10.116.12.170:8080/vars/metadades but have http://localhost:3000/vars/metadades. The json() call fails.

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected): [email protected]
  2. node -v: v6.9.1
  3. npm -v: 4.0.5

Then, specify:

  1. Operating system: Linux 4.4.0-57-generic
  2. Browser and version: Google Chrome 55

aaronplanell avatar Jan 02 '17 13:01 aaronplanell

Forget it. It was my fault. It was a problem of the Server. I used the @CrossOrigin label in Spring and now works. Sorry for the mistake.

aaronplanell avatar Jan 02 '17 13:01 aaronplanell

In my case throwing cross origin error backend on rails (s3 server) but my project is on localhost

shabanraza avatar Jan 11 '17 15:01 shabanraza