Skip to content
Back

How to work with client and server SDK

  • 0
  • Self Hosted
  • Auth
  • Web
Guille
14 May, 2024, 17:31

Hey, how should I work with the two SDK

I'm using Nextjs so al the authentication process is made with the node-sdk but there are some queries to the database I need to do with the client SDK

Currently I'm doing:

TypeScript
const sessionClient = () => {
  const session = getCookie(SESSION_COOKIE_TOKEN);
  return new Client()
    .setEndpoint(Server.endpoint || "")
    .setProject(Server.project || "")
    .setSession(session || "");
}

const client = sessionClient();
const databases = new Databases(client)

However when I do a request I got an error 401

When I see the the request headers I see the session token (see the image), what I'm doing wrong?

TL;DR
The developer is trying to work with both client and server SDKs in a Next.js project. They are using the `node-sdk` for authentication and the client SDK for database queries. They are experiencing a `401` error even though the session token is present in the request headers. There may be an issue with the way the session token is being set or passed. **Solution:** - Double-check the session token generation and ensure it is correctly passed to the client SDK. - Make sure the server SDK and client SDK configurations are properly set up. - Debug the authentication flow to identify any issues in the session establishment process.
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