3

I was wondering if it would be possible to call my API from the getServerSideProps like:

await axios.post('/api/auth/refresh-token');

and use previously set user cookies on the server-side.

Right now, whenever I do that, the server thinks it's a different session and cookies are not available.

I use next-iron-session and if I call the API on the client-side everything is fine and session is available.

Damian Kociszewski
  • 283
  • 1
  • 5
  • 20
  • 1
    Do not call an internal API from `getServerSideProps`: [Internal API fetch with getServerSideProps? (Next.js)](https://stackoverflow.com/questions/65752932/internal-api-fetch-with-getserversideprops-next-js/65760948#65760948). You can access the cookies in `getServerSideProps` through the context object `ctx.req.cookies`. – juliomalves Jun 04 '21 at 17:48

0 Answers0