elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
9.74k stars 207 forks source link

Domain is not set when using cookie.remove() #708

Open binamralamsal opened 2 months ago

binamralamsal commented 2 months ago

What version of Elysia.JS is running?

1.0.27

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

const app = new Elysia({
  cookie: {
    httpOnly: true,
    secure: true,
    domain: env.FRONTEND_DOMAIN,
    sameSite: "lax",
  },
})

I have set my domain while intiailizing Elysia. It is set when I set a cookie in headers but when I remove the cookie, domain value is not in headers.

image

What is the expected behavior?

Domain value should be while removing cookie

What do you see instead?

No response

Additional information

No response

binamralamsal commented 2 months ago

Found out you have to put your domain in your service locator and not main Elysia handler.

binamralamsal commented 2 months ago

Reopening this because it sometimes works and sometimes doesn't, this is pretty weird.

binamralamsal commented 2 months ago

Well, looks like this doesn't work as I expected when using cookie schema (I was using it on logout route only) or probably I am dumb to not understand this. Removing cookie schema works fine but I am not sure if it should be considered an issue or not.

If this is an intentional behavior, then you can close this issue and please also provide short explanation as I am extremely confused.