
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
- Hi, can anyone give me some free credits...
Hi, can anyone give me some free credits to upgrade to pro for a few months?
- The current user is not authorized to pe...
Hello, I am attempting to receive fetch data from databases.listDocuments with each of its env parameter data for it to be shown on a NextJS project. However I ...
- Native Sign in with Google/Apple Flutter
Is native sign in with google / apple in Flutter possible with Appwrite?
