aitok-ai / LibreChat

Enhanced ChatGPT Clone: Features OpenAI, Bing, PaLM 2, AI model switching, message search, langchain, Plugins, Multi-User System, Presets, completely open-source for self-hosting. More features in development
https://discord.gg/CEe6vDg9Ky
MIT License
3 stars 1 forks source link

[Bug][zhao.toatu.com]: Logout Error #180

Closed jinzishuai closed 7 months ago

jinzishuai commented 7 months ago

Contact Details

No response

What happened?

Log out fails but this is not happening on the https://chat.aitok.ai/

image

Steps to Reproduce

  1. login
  2. logout

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Screenshots

No response

Code of Conduct

jinzishuai commented 7 months ago

API Failure

POST to https://zhao.toatu.com/api/auth/logout without data

got 500 (Internal Server Error)

{
    "message": "The \"data\" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null"
}
jinzishuai commented 7 months ago

This happens to curl command directly to chat.aitok.ai

╭─    ~ ···································································································································· ✔  13s   base   23:10:36  
╰─ curl --location --request POST 'https://chat.aitok.ai/api/auth/logout' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0OGJlZmIxMGJjMmI2MWYxNjZhNTI2MiIsInVzZXJuYW1lIjoiamluemlzaHVhaSIsInByb3ZpZGVyIjoibG9jYWwiLCJlbWFpbCI6Imppbnppc2h1YWlAZ21haWwuY29tIiwiaWF0IjoxNzExNjAzMDIzLCJleHAiOjE3MTIyMDc4MjN9.ookAVF8R9mfJyunvkqRDc-OVMp9dBPoGadE_wTpHnNk'
{"message":"The \"data\" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null"}%  
jinzishuai commented 7 months ago

it works with Cookie to set refreshToken

╭─    ~/src/jinzishuai/LibreChat/api    jinshi/stripe-pay-page-link ············································································· ✔  base   23:52:54  
╰─ curl --location --request POST 'https://chat.aitok.ai/api/auth/logout' \
--header 'Cookie: refreshToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0OGJlZmIxMGJjMmI2MWYxNjZhNTI2MiIsImlhdCI6MTcxMTYwMzAyMywiZXhwIjoxNzEyMjA3MTUwfQ.gWME9syA0b6kWcZc1qbjWDwqRGyMXtyYnjpQLyBGrKE' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0OGJlZmIxMGJjMmI2MWYxNjZhNTI2MiIsInVzZXJuYW1lIjoiamluemlzaHVhaSIsInByb3ZpZGVyIjoibG9jYWwiLCJlbWFpbCI6Imppbnppc2h1YWlAZ21haWwuY29tIiwiaWF0IjoxNzExNjAzMDIzLCJleHAiOjE3MTIyMDc4MjN9.ookAVF8R9mfJyunvkqRDc-OVMp9dBPoGadE_wTpHnNk' \
--data ''
{"message":"Logout successful"}% 
jinzishuai commented 7 months ago

The difference is in the refreshToken in the Cookie

working: chat.aitok.ai

image

Not working: zhao.toatu.com

image
jinzishuai commented 7 months ago

It is very likely the problem is in how CloudFront handles cookies.

jinzishuai commented 7 months ago

Solution: Change Cookie Caching from None to All

image