Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@GrosSacASac

Description

@GrosSacASac

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:[email protected]/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions