0

I have a node js server, and after post request to the server, I insert some data into the database, after that, I want to redirect my client into the other external web-page("google.com" for example) but I want to redirect with Basic auth header, How can I do that?

I have tried to set the header manually, but it does not work

 const auth = "Basic " + new Buffer.from("test" + ":" + "testPassword").toString("base64");
  res.setHeader('Authorization', auth);

and after db insertion I do this

enter code here return res.redirect(result.data.registrationCreditUrl);
jankal
  • 1,090
  • 1
  • 11
  • 28
Akezhan
  • 73
  • 6
  • 2
    Redirect will execute a new http request and your headers will be lost. Use `query string` or `session` – Hasta Tamang Mar 18 '19 at 19:05
  • Here's the similar post with same answer to what @Hasta mentioned: https://stackoverflow.com/questions/32235438/set-express-response-headers-before-redirect – noobius Mar 18 '19 at 19:09

1 Answers1

0

Short answer: You can't.

A redirect just sends the user to another page. It doesn't send headers or other information besides the url.

jankal
  • 1,090
  • 1
  • 11
  • 28