Send a set-cookie header to a redirect url in node.js

后端 未结 2 1859
情话喂你
情话喂你 2021-02-07 05:03

I am using node.js request module to fetch an id_token from an API. After fetching that id_token I want to send a redirect uri response with a se

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-07 05:47

    After lots of trials and errors and googling I was finally able to achieve my goal. In order to send a cookie with an expiry to the the redirect URL, I just added

    s = body.exp.toUTCString();
    res.cookie('id_token' ,body.id_token, {expires: s});
    res.redirect(302, 'http://localhost:8080');
    

提交回复
热议问题