#Access the accessToken in getServerSideProps

3 messages · Page 1 of 1 (latest)

fast dove
#

If you have the accessToken in localstorage I don’t think you can, because localStorage is for the browser, however you could save that in a cookie and use it in serverSideProps

summer olive
#

Why not just store the accesstoken in a cookie as well, it will get automatically sent by the browser. additionally localstorage doesnt provide any securiry, ideally you would store your AT in an httpOnly cookie as well

#

you could access the authorization header in getServerSideProps as well as do res.setHeader if needed, but I recommend entertaining the idea of storing the AT in an httpOnly cookie as well