Proxy POST issue with react-scripts 1.0.x and standard HTML (login) form
See original GitHub issueMy app proxies all unknown requests to an external server (java).
Since version 1.0.0 (and up to latest 1.0.11) I cannot login any more. The login POST request is rejected with status 404 (the browser shows “Cannot POST /api/login”).
If I roll back to 0.9.x I can login again.
If already logged in, all other POST requests seem to be accepted.
Here is the network capture of the request:
POST /api/login HTTP/1.1
Host: 0.0.0.0:3000
Connection: keep-alive
Content-Length: 26
Cache-Control: max-age=0
Origin: http://0.0.0.0:3000
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.100 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
DNT: 1
Referer: http://0.0.0.0:3000/logout
Accept-Encoding: gzip, deflate
Accept-Language: fr,en-US;q=0.8,en;q=0.6
Cookie: sessionToken=339102761274932417
login=admin&password=admin
HTTP/1.1 404 Not Found
X-Powered-By: Express
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Content-Length: 23
Vary: Accept-Encoding
Date: Thu, 24 Aug 2017 14:37:43 GMT
Connection: keep-alive
Cannot POST /api/login
Is this a bug report?
EDIT: I guess not since I found the explanation in the user guide.
Maybe the doc on proxying could say that login forms implemented in pure HTML will not work since it generates an Accept:text/html header.
Can you also reproduce the problem with npm 4.x?
4.x not tried. I’m using 6.11.2
Which terms did you search for in User Guide?
“proxy”
I found the following information:
The development server will only attempt to send requests without a text/html accept header to the proxy.
This seems to explain my problem since my login form is a standard HTML form. I’m not sure I can prevent the browser to send text/html in its accept header.
Does it mean I have to tweak my login component to perform some ajax call instead of relying on standard HTML?
Environment
node -v
: v6.11.2npm -v
: 3.10.10yarn --version
: 0.27.5npm ls react-scripts
: 1.0.11
Then, specify:
- Operating system: linux
- Browser and version: not relevant
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:13 (4 by maintainers)
Top GitHub Comments
Can I reopen this issue? I have the similar issue
@Johnny00520 file new issue