Back

Cannot get cookies inside function so I can auth

  • 1
  • Functions
wintercounter✌🏼
11 Oct, 2023, 06:47

check it here

TL;DR
The user is having trouble accessing cookies within a function to authenticate users. They tested with cookies for the whole subdomain, but it is still not working. The function code returns the request object. The SDK is set to "https://api.vegas/v1". The user suspects that the issue may be with Appwrite or Cloudflare. No solution has been found yet, but the user has created a ticket for support. Setting cookies in devtools and checking the req object does not show any logged cookies.
wintercounter✌🏼
11 Oct, 2023, 06:47

i'm returning the complete req object

wintercounter✌🏼
11 Oct, 2023, 06:47

try setting any cookie in devtools, nothing will be logged

wintercounter✌🏼
11 Oct, 2023, 06:49

i went with creating execution with the sdk now, as that's not using the the subdomain

wintercounter✌🏼
11 Oct, 2023, 06:50

but if I need session, using a subdomain is a no-go currently

wintercounter✌🏼
11 Oct, 2023, 06:50

not sure if the issue is in appwrite or with cloudflare

wintercounter✌🏼
11 Oct, 2023, 06:51

i opened a ticket for them, so far they are clueless 😄

Drake
11 Oct, 2023, 16:51

what's the code?

Drake
11 Oct, 2023, 16:51

when using the SDK, what did you set the endpoint to?

wintercounter✌🏼
11 Oct, 2023, 17:27

you mean the code of the function?

wintercounter✌🏼
11 Oct, 2023, 17:28

the function's code is just

TypeScript
export default async ({ req, res, log, error }) => {
    return res.send(JSON.stringify(req, null, 2), 200)
}
wintercounter✌🏼
11 Oct, 2023, 17:29

the sdk is set to https://api.vegas/v1

wintercounter✌🏼
11 Oct, 2023, 17:29

but with the sdk i have no problem as that's not using the subdomain

Drake
14 Oct, 2023, 23:05

And how exactly are you calling this?

wintercounter✌🏼
15 Oct, 2023, 05:15

I open the URL

wintercounter✌🏼
15 Oct, 2023, 05:16

in browser

Drake
15 Oct, 2023, 19:41

Hmm ya I don't think cookies would pass because the cookie is for a parent domain. What are you trying to do?

wintercounter✌🏼
15 Oct, 2023, 20:12

cookies set with . or without should work on any level

wintercounter✌🏼
15 Oct, 2023, 20:13

that's why the browser is sending it

wintercounter✌🏼
15 Oct, 2023, 20:13

i wanted to check if the user is authenticated or not

wintercounter✌🏼
15 Oct, 2023, 20:15

i also tested with a cookie for the whole subdomain, that's also missing

wintercounter✌🏼
15 Oct, 2023, 20:15

so there's clearly a bug somewhere

wintercounter✌🏼
15 Oct, 2023, 20:16
Drake
15 Oct, 2023, 21:11

This is weird...if it's being sent from the client, I would expect it to be passed along based on this code:

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more