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
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...