-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Require http:// or https:// at front of proxy URL #800
Comments
It will be hard for us to help without at least a project reproducing this. |
Ok, I will provide a minimal project with both the frontend and the API. The API will be written in Ruby, but hopefully that will be enough to identify the issue. |
Here's the demo. 😃 The only thing I have modified is adding the |
@silvenon were you ever able to figure this out? Running into the same issue. However, I have a Rails5 server running on port 3333 in API mode which doesn't require any auth.
|
@BryIsAZombie unfortunately no. 😞 I suck at this stuff, hopefully someone from the team will be able to help… |
@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. |
@BryIsAZombie glad you figured it out! I'm not using Rails, though. I wonder which dependency in v5.0.0.1 fixed it… |
I had this issue. |
Also seeing this issue. However when I console.log(process.env.PORT) I notice it's null. |
I had this issue right after I tried using socket.io, couldn't solve it, did you find any solution ? |
I'm seeing this issue also. Tried using react-scripts with python SimpleHttpServer and also ExpressJS to no avail even when trying many different ports. |
Just ran the demo application and it worked for me. |
@silvenon would you like to provide me with more details? 😄 |
@Timer for some reason this bug is no longer present in that demo, I'm not sure what changed. If I had created a Yarn lockfile sooner, maybe we could've tracked it to a certain dependency, but this way I don't know. Anyway, closing this. |
Steps to reproduce: lucas@localhost ~/test-app Mon 20 Feb 2017 09:30:05 AM MST
➜ create-react-app --version
1.0.4
$ create-react-app test-app
$ cd test-app
{
"name": "test-app",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.9.0"
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "localhost:5001"
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tag above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start`.
To create a production bundle, use `npm run build`.
-->
</body>
<script src="/myfile.js"/>
<a href="/badlink">Link to the proxy server</a>
</html> In another terminal: python -m http.server 5001 Then run the app $ npm start
Compiled successfully!
The app is running at:
http://localhost:3000/
Note that the development build is not optimized.
To create a production build, use npm run build.
Proxy error: Could not proxy request /myfile.js from localhost:3000 to localhost:5001.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (EINVAL). Clicking on the link also causes |
Actually, my problem was not including the full URI, changing the proxy to |
Perhaps we should require the proxy to be a full URL? Would you like to send a PR for this? |
I have the same issue and have been suffering for two days now. I also included the full URI, still didn't work. Other than that, everything seems to be same as what Inunno has done. I have the same error going too. |
Arvin6, I have the same problem too. Don't know what to do. |
If anybody could provide us with a workaround for it, it'll help us move forward with our projects. So, Captain? |
We cannot help without a project reproducing this. Please provide one. 😄 |
Ahh. Got it to work. Actually my problem was in the fetch API call. Proxy had no problem. The information in here was valuable and helped me track my problem. Thank you everyone. |
@Arvin6 can you explain how you solve it? I think it will help the people who is facing a similar issue. |
@viankakrisna , Surely. My problem wasn't really proxy. It was because I didn't use full URL in proxy at package.json. It needs to be 'http://localhost:[your port]' . And the other problem was that I didn't jsonify the response. I was parsing the response as is. So, adding a |
For those having this problem, add http:// to the proxy entry in package.json thus |
If someone wants to send a PR requiring proxy to match |
I am taking this |
Okay, awesome! |
I have same problem this week (on MacBook Pro)
but my workmate (on Windows 10) is OK, 😩 |
I have same problem this week (on Winodws) |
Hi, Command I used to start my server before: After some research I found out that this could be solved with changing |
@jdrzejb It works! Thanks man. Saved my day. :) |
@jdrzejb luckily I am not the only full-stack developer using CRA and Silex, thanks! |
I have faced the same issue today on Windows, but when tried run exactly the same project on macbook worked smoothly without any issues. edit: in my case problem was with env variables which is not universal solution, but i'll explain anyway: I got client(port 3000) & server(port 5000) run concurrently. Client-react package was telling me that it can't proxy to 5000 bc my NODE_ENV was set globally on production not on dev, so my server wasn't working as it should and i solve it by "unset NODE_ENV", you can check yours by "echo $NODE_ENV" or similar |
This solved the problem for me, |
I've tried all of the solutions mentioned above but non is working for me, any new solution to this? (Update) For my case, once I stopped using nodemon to start my server, the error never occur again. Now it's working fine when I use "node server.js". |
This might be helpful for people using nodemon or other similar stuff to auto restart server, atleast for me it was. I was using nodemon which monitors file changes and restarts the server if some change is detected. So I just had to ignore the react app directory from nodemon:
|
This work for
|
I have some error. |
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:
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:
Environment
npm ls react-scripts
: [email protected]node -v
: v6.3.0npm -v
: 3.10.3Reproducible Demo
silvenon/demo-cra-basic-auth
The text was updated successfully, but these errors were encountered: