Skip to content
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

Basic user@pass is dropped (worked in 2.6.1) #1330

Closed
GrosSacASac opened this issue Oct 7, 2021 · 1 comment
Closed

Basic user@pass is dropped (worked in 2.6.1) #1330

GrosSacASac opened this issue Oct 7, 2021 · 1 comment
Labels

Comments

@GrosSacASac
Copy link

GrosSacASac commented Oct 7, 2021

I didn't see it mentioned in the upgrade guide

Reproduction

Steps to reproduce the behavior:

  1. Create an url that contains a user and password
  2. use fetch
  3. look at what was sent
  4. (Basic http header is missing)
import fetch from "node-fetch";

if (!globalThis.fetch) {
    globalThis.fetch = fetch;
}


const baseUrl = `https://XXX:YYY@letz.social/echo-test/zzz`;

fetch(baseUrl, {
    headers: {
        Accept: `application/json`,
    },
}).then(response => {
    if(!response.ok) {
        throw response.statusText;
    }
    return response.text();
}).then(text => {
    console.log(text);
});

Observed behavior (3.0.0)

node test.js
/echo-test/zzz    Method: GET

    Headers:

Host: letz.social
Connection: close
accept: application/json
accept-encoding: gzip,deflate,br
user-agent: node-fetch

    Body:

Expected behavior (2.6.5)

node test.js      
/echo-test/zzz    Method: GET

    Headers:

Host: letz.social
Connection: close
Accept: application/json
User-Agent: node-fetch/1.0 (+https://github.com/bitinn/node-fetch)
Accept-Encoding: gzip,deflate
Authorization: Basic WFhYOllZWQ==

    Body:


Screenshots

Your Environment

software version
node-fetch 3.0.0
node 16
npm
Operating System

Additional context

https://letz.social/echo-test/xyz is a simple echo http server
https://github.com/GrosSacASac/echo-http-node

@GrosSacASac GrosSacASac added the bug label Oct 7, 2021
@jimmywarting
Copy link
Collaborator

jimmywarting commented Oct 7, 2021

we decided to completely drop support for it in #1268 it now throws an error if you try to construct a Request with a auth-url (doe it's not released)
the solution is to do basic auth header

... Should update the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants