Skip to content

🐛 Bug Report: Cookies aren't passed #90

@ReindertKorver

Description

@ReindertKorver

👟 Reproduction steps

When I use this package: dart_appwrite: 16.1.0 in my jaspr project and I try to sign in to create a session the cookies aren't passed. I first tried figuring out if it was some security issue but I got it working by manually sending the requests.
For example when I run this code:

var acc = Account(client);
await acc.createEmailPasswordSession(email: email, password: password);
await acc.getSession(sessionId: 'current');

I get the cookie from my self hosted server:

Image

But the get current session request does not have the cookies attached when sending the request:

Image

👍 Expected behavior

When I send it manually like this:

final response = await html.HttpRequest.request(
        url,
        method: 'POST',
        requestHeaders: {
          'Content-Type': 'application/json',
          'X-Appwrite-Project': value,
        },
        sendData: jsonEncode({
          'email': email,
          'password': password,
        }),
        withCredentials: true, // <-- this is essential
      )

And I request the session again:

final response = await html.HttpRequest.request(
        '$endPoint/account/sessions/current',
        method: 'GET',
        requestHeaders: {
          'X-Appwrite-Project': value,
        },
        withCredentials: true, 
      )

The cookies are attached correctly:

Image

So I tried to patch this package locally but I couldn't get it to work but I'm almost certain its in this line:

_httpClient = BrowserClient();

Which should be:

_httpClient = BrowserClient()..withCredentials = true;

Maybe I'm wrong but let me know if I am :)

👎 Actual Behavior

Cookies aren't send.

🎲 Appwrite version

Version 0.10.x

💻 Operating system

Linux

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions