
Hi, is out there an example how to authenticate with appwrite with Node.js or Express.
I tried https://github.com/appwrite/playground-for-web, but this example does not have multisite authentication like the todo-demos for the other languages on GitHub.
Would be either great to have such a web-todo-demo or if anybody can share an example of how to authenticate with express?
Thanks ahead for any help 🙂

Honestly, I would not recommend using express because Appwrite is supposed to be your back-end server, and adding an extra layer in between makes things complicated.
The client SDK was designed to be used on the front ned, so you may not be able to use it in your express app. If you really want to use express and Appwrite's authentication mechanism, you'll have to manually make the API call to create a session and manually manage the session cookie returned from Appwrite.

Ok Thanks.

I just wanted to build on top of the web-playground example. Not sure how to build a web app that's multisite without express and has appwrite authentication.

the web playground is just a sample to show how the SDK works. you definitely shouldn't build on top of it as it doesn't follow any sort of best practices for building an app.

Not sure how to build a web app that's multisite
What do you mean by multisite?

With multisite i mean something like the todo demos (with restricted and unrestricted sites) and without react or similar. I tried it with plain html, node and appwrite as backend but i am not sure how to handle the restricted sites

Again, using express is much more complicated because you must manage the session yourself.
If you really want to, you'll have to handle login:
- accept the user's email and password
- manually send that to Appwrite (w/o the SDK)
- grab the session cookie from the response
- store that in a session in your express app
Then, when someone tries to access a restricted page your express app would need to:
- try to pull the appwrite session out of the express session
- make an
account.get()
API call to Appwrite to verify the session is valid - send the user to the restricted page
- otherwise, send the user to the login page

If you build a single-page app, you wouldn't need to do 2, 3, 4 from the login and 1 from the second part.

Ok thanks for your answer 🙂
Recommended threads
- How to detect user disconnection?
I'm creating a 1v1 challenge using realtime and i want to trigger a function when the user disconnect... how to make this using Appwrite Realtime? i searched i...
- Custom domain issue
Hello following another post I'm creating dedicated post according to my project ID: 67ffbd800010958ae104 I deployed for debug my React Native app in web, chrom...
- Appwrite DNS Record Invalid on 123reg
So I go to the project settings and add in my domain name. Then when I add the CNAME record to 123reg it says that ''Record data is invalid'' As seen in the s...
