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

Userinfo is ignored after a redirect to same origin #1351

Closed
2 tasks done
lpinca opened this issue Jul 9, 2020 · 0 comments
Closed
2 tasks done

Userinfo is ignored after a redirect to same origin #1351

lpinca opened this issue Jul 9, 2020 · 0 comments
Labels
bug Something does not work as it should ✭ help wanted ✭ regression Something does not work anymore
Milestone

Comments

@lpinca
Copy link
Contributor

lpinca commented Jul 9, 2020

Describe the bug

  • Node.js version: v14.5.0
  • OS & version: macOS 10.15.5

The Authorization header is not sent after a redirect to same origin if the initial request uses a URL with the userinfo subcomponent. It seems this stopped working with got@10.

Refs: MONEI/Shopify-api-node#390

Actual behavior

The Authorization header is not sent.

Expected behavior

The Authorization header is sent.

Code to reproduce

const assert = require('assert');
const got = require('got');
const http = require('http');

const server = http.createServer(function (request, response) {
  if (request.url === '/redirect') {
    assert.strictEqual(request.headers.authorization, 'Basic Zm9vOmJhcg==');
    response.statusCode = 303;
    response.setHeader('location', 'http://localhost:8080/');
    response.end();
    return;
  }

  assert.strictEqual(request.headers.authorization, 'Basic Zm9vOmJhcg==');
  response.end();
});

server.listen(8080, async function () {
  await got('http://foo:bar@localhost:8080/redirect');
});

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as it should ✭ help wanted ✭ regression Something does not work anymore
Projects
None yet
Development

No branches or pull requests

2 participants