RevereCRE / relay-nextjs

⚡️ Relay integration for Next.js apps
https://reverecre.github.io/relay-nextjs/
MIT License
250 stars 30 forks source link

This is a bit tricky for two reasons: #25

Closed AngelLoredoAlvarez closed 2 years ago

AngelLoredoAlvarez commented 2 years ago

This is a bit tricky for two reasons:

  1. I'm not sure having the Relay environment change network after initializing works?

  2. Requests must be made on both the client side and server side, so using local storage based authentication won't work because it's not available on the server.

For these reasons I recommend using cookies for your auth solution.

Originally posted by @rrdelaney in https://github.com/RevereCRE/relay-nextjs/issues/20#issuecomment-888382023

AngelLoredoAlvarez commented 2 years ago

This is a bit tricky for two reasons:

  1. I'm not sure having the Relay environment change network after initializing works?
  2. Requests must be made on both the client side and server side, so using local storage based authentication won't work because it's not available on the server.

For these reasons I recommend using cookies for your auth solution.

Originally posted by @rrdelaney in #20 (comment)

According to this issue, the recommended way to authenticate is with cookies, my question is, that way works in both relay environments?, or just in the client environment?

rrdelaney commented 2 years ago

I'd recommend using cookies for both. For the server-side render you should have access to cookies in req.cookies and on the client-side render make sure you're passing cookies along with your HTTP request to the server.

AngelLoredoAlvarez commented 2 years ago

I'd recommend using cookies for both. For the server-side render you should have access to cookies in req.cookies and on the client-side render make sure you're passing cookies along with your HTTP request to the server.

Got it!!!, thank you again!!!!!