question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Require http:// or https:// at front of proxy URL

See original GitHub issue

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

  1. npm ls react-scripts: react-scripts@0.6.1
  2. node -v: v6.3.0
  3. npm -v: 3.10.3
  4. Operating system: macOS Sierra (10.12)
  5. Browser and version: Chrome 53.0.2785.116

Reproducible Demo

silvenon/demo-cra-basic-auth

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:40 (10 by maintainers)

github_iconTop GitHub Comments

15reactions
malone5commented, Oct 21, 2016

@silvenon I am having the same exact issue you are having, so you are not alone. Will report back if I come to a solution.

13reactions
jdrzejbcommented, Jul 10, 2017

Hi, I just wanted to post a solution that worked for me. Maybe it will save someone few hours. I am developing PHP backend (Silex). After starting server and CRA app I always got ECONNREFUSED when using built-in proxy.

Command I used to start my server before: php -S localhost:8899 -t web

After some research I found out that this could be solved with changing localhost to 0.0.0.0: php -S 0.0.0.0:8899 -t web

Read more comments on GitHub >

github_iconTop Results From Across the Web

http to https node proxy - Stack Overflow
I needed a HTTP->HTTPS node proxy for unit testing. ... server receives the CONNECT request, it sets up a tunnel to the HTTPS...
Read more >
Proxy HTTPS requests to a HTTP backend with NGINX
The scenario I want to achieve is: Client makes HTTP request to nginx which is redirect to the same URL but over HTTPS;...
Read more >
Proxy servers and tunneling - HTTP - MDN Web Docs
Identifies the originating IP addresses of a client connecting to a web server through an HTTP proxy or a load balancer.
Read more >
HTTPS behind your reverse proxy - Reinout van Rees
HTTP/HTTPS connections from browsers (“the green cloud”) go to two reverse proxy servers on the outer border of our network.
Read more >
HTTPS-Proxy: Domain Name Rules - WatchGuard Technologies
Domain Name Rule Actions · Allow — Allows the HTTPS request. · Inspect — Uses the specified HTTP proxy action or content action...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found