Back

Correct way of supporting SSR & CSR (Next.js 14)

  • 0
  • Auth
  • Web
Faye
6 Apr, 2024, 18:26

Heyo!

Does anyone have a valid way of being able to support both SSR and CSR? For example, what if I want to do account.get() on a client sided page, following the tutorial on the docs will show a 401 on CSR, but 200 on SSR.

The web sdk client creates cookies on the domain where the API is located (for example cloud.appwrite.io), but not on the domain itself. This is fine, but if you sign in via SSR, the cookies will not exist on that domain and so the CSR side will not work. Any idea how to support both? πŸ€”

TL;DR
Title: Supporting SSR & CSR with Next.js 14 Developers are looking for help to support both SSR and CSR. A common issue is facing 401 error on CSR after following tutorials that work fine on SSR. Cookies created by web SDK client are not available on both domains causing authentication problems. One solution is to manage cookies globally using a package like js-cookie to ensure they work on both sides.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more