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

后端 未结 2 1857
情话喂你
情话喂你 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');
    
    0 讨论(0)
  • 2021-02-07 05:55

    in express 4.16.3 , you must set

    res.cookie()

    before

    res.redirect()

    and it works for me, without error

    0 讨论(0)
提交回复
热议问题