Hi,
I want to use a custom Websocket Server (using Bun) for my application. However I cant really figure out authentication on custom servers. Session cookies seem to be HTTP and secure only, which prevents me from reading them in localhost.
How would I implement the authentication here?
Bun.serve({
port: parseInt(process.env.PORT as string),
hostname: "localhost",
development: true,
async fetch(req, server) {
// ... authenticate here
if (server.upgrade(req)) {
return undefined;
}
return new Response("Upgrade failed", { status: 500 });
},
websocket: {
// ...
},
});
the way discord handle websocket is that :
- the user connects to the websocket
- then sends a message with the auth infos (e.g. the discord token)
- if the server receive the auth infos, it checks it and start the handle for the messages
- if the user does not send the auth message in 60s, the server disconnect the user
follow the same flow for SSR login: https://appwrite.io/docs/products/auth/server-side-rendering.
Make sure you use a custom endpoint that matches your backend endpoint.
Then, the appwrite cookie will be sent to both appwrite and your backend and can be used for auth
Recommended threads
- Bulk API limitations in self-hosted serv...
Environment: Appwrite Selfhost SDK: node-appwrite 28.0 Calling `upsertRows` (also applies to `createRows`/`updateRows`/`deleteRows`) with more than 100 rows fa...
- Self Hosted GitHub connection not adding...
After upgrading to 1.9.6 i noticed that i cannot search for new repositories when trying to add new functions. I removed the existing github connection via Set...
- Unable to init function via cli
Hello! I have created a new self hosted instance of appwrite 1.9.6 and have connected to that insatnce with the cli 27.2.0 that was released a few hours ago. Wh...