401 response code is shown as 200
See original GitHub issuevar nodeFetch = require("node-fetch")
nodeFetch('https://bitbucket.org/atlassian/foo/get/master.zip').then((res) => {
console.log(res.status);
});
This URL returns 401 but for some reason, I get back 200.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
401 Unauthorized - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 401 Unauthorized response status code indicates that the client request has not been completed ...
Read more >How to Quickly Fix the 401 Unauthorized Error (5 Methods)
The 401 (Unauthorized) status code indicates that the request has not been applied because it lacks valid authentication credentials for the ...
Read more >HttpGet 401 status code followed by 200 status code
v(this, "Response code status: " + status); // code status = 200 (even if a 401 and then a 200 are visible in...
Read more >401 Unauthorized Error: What It Is and How to Fix It
The 401 Unauthorized Error is an HTTP response status code indicating that the client could not authenticate a request.
Read more >HTTP/1.1: Status Code Definitions
This class of status code indicates that the client's request was successfully received, understood, and accepted. 10.2.1 200 OK. The request has succeeded....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I will be closing this as it seems like a misunderstanding of server behavior.
@1999 that zip url requires authentication. So when you try to access it without any auth info it will redirect you to a login page. The login page is returning the successful
200
. Curl wont follow redirects with just thecurl
command. The-L
flag should make curl follow the redirect and return a200
.3xx
codes indicate a redirection. fetch defaults to follow the redirects which is why without that param it is returning a200
.