Require http:// or https:// at front of proxy URL
Created by: silvenon
Description
I'm having trouble with getting the proxy feature to work. I'm not sure if it's because my API requires HTTP basic authentication. This is my code:
// package.json
{
// ...
"proxy": "http://localhost:4000"
}
fetch('/users', {
headers: {
'accept': 'application/json',
'authorization': 'Basic ' + btoa(process.env.REACT_APP_USERNAME + ':' + process.env.REACT_APP_PASSWORD),
'content-type': 'application/vnd.api+json',
},
});
Expected behavior
I expected it to work, the headers are correct because http://localhost:4000/users
works fine. I don't have CORS issues because I set my API to accept any origin in development, but I still want to achieve this via the proxy feature.
Actual behavior
I get this error:
Proxy error: Could not proxy request /meetings from localhost:3000 to http://localhost:9292.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).
Environment
-
npm ls react-scripts
: react-scripts@0.6.1 -
node -v
: v6.3.0 -
npm -v
: 3.10.3 - Operating system: macOS Sierra (10.12)
- Browser and version: Chrome 53.0.2785.116