
Currently I am login and control what can user see with SSR but I would like to upload files directly to appwrite without upload files first to my server due avoid innecesary traffic. I tried using "{ 'X-Fallback-Cookies': 'my-cookie-name-for-session-token' }" for the headers but I can not receive anything different than 401. Do I have to decide if I want between SSR and SCR? I mean, should I decide if I want my server as middle point between the frontend and backend (appwrite) or use directly the backend?
Is there a way to specify which cookie name should Appwrite use?
I have configured custom domain name but I am testing on localhost.

Set the token from your cookie as the session on your client
const token = cookies.get('cookie');
const client = new Client().setEndpoint().setProject().setSession(token);

You mean inject it into the client side code, right? I though about it but not sure about safety π

But it seems as the only one solution if bandwidth is the top priority π

You'll need a new appwrite client avaliable on the client side if you want to directly upload from the client.

Thank you @Kenny just want to confirm that in case I was missing something in the doc... I was looking like mad person π

im on same boat, according to what i read from here, im doing this:
Php:
// Initialize admin client here
// ...
// Get email and password from request
$email = $_POST['email'];
$password = $_POST['password'];
try {
$account = new Account($adminClient);
// Create the session using the Appwrite client
$session = $account->createEmailPasswordSession($email, $password);
// Set the session cookie
setcookie('session', $session['secret'], [
'httpOnly' => true,
'secure' => true,
'sameSite' => 'strict',
'expires' => strtotime($session['expire']),
'path' => '/',
]);
echo json_encode(['success' => true]);
} catch (Exception $e) {
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}```
JS (web) part:
```const token = Cookies.get('session');
console.log('Token: ',token);
const client = new Appwrite.Client().setEndpoint(endpoint).setProject('abc').setSession(token);
console.log('Client: ', client);```
Console shows this:
`Token: undefined`
```Client:
config: Object { endpoint: "https://abc.com", endpointRealtime: "wss://abc.com", project: "abc", β¦ }
endpoint: "https://abc.com"
endpointRealtime: "wss://abc.com"
jwt: ""
locale: ""
project: "abc"
ββsession: undefined```
According to what i see, its because the cookie is marked as HttpOnly, and it can only be accessed by the server, not via JavaScript.
So.. do i need to disable the httponly? or is there a better approach to this?
Recommended threads
- Query.equal error
Hi guys. I'm using Appwrite Cloud, and I'm using version 21 of node-appwrite to benefit from transactions. The problem is I seem to be getting an error when I u...
- Cannot access my Appwrite database on th...
Hello guys, I am currently developing a web app and using appwrite for authentication, database, storage and messaging. It was working well but since yesterday...
- Nuxt Middleware Support
So I'm trying to protect some routes so that the user is redirected back to the login screen should they not have an active session. However, I'm stuck in a lo...
