D
D
Dumb as a cork2020-03-14 02:37:53
Sessions
Dumb as a cork, 2020-03-14 02:37:53

How to make a request from server to server?

How to make a request from server to server (API) where cookies are used as auth and not jwt

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Cheremkhin, 2020-03-15
@Che603000

First you need to log in to server 2 and save cookies in a variable (cookie)
Then, with each request to server 2, substitute cookies in the header

// запрос с сервера 1
const options = {
    url: ' http://server2.com', 
    method: 'POST',
    headers: {
      'Cookie': cookie // cookie - то что вы получили в куки при авторизации на сервере http://server2.com 
      ...
    }
};
request(options, (err, res, data) =>{
 ...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question