OvidijusParsiunas / deep-chat

Fully customizable AI chatbot component for your website
https://deepchat.dev
MIT License
1.27k stars 176 forks source link

I can not send a cookie #42

Closed wysstartgo closed 7 months ago

wysstartgo commented 7 months ago

:request="{ url: 'http://localhost:8080/chat-stream-flowable', method: 'POST', headers: { charset: 'utf-8' }, additionalBodyProps: { field: 'value' }

when I use the stream mode as above,I can not get cookie in server side.

OvidijusParsiunas commented 7 months ago

Hey @wysstartgo. Just to make sure I understand the problem correctly, is the cookie not being attached when you are using the stream mode with stream property set to true or if it just doesn't work for regular requests?

The thing with cookies is - is that by default the browser appends them to the outgoing fetch requests as long as the target server is on the same origin as the browser (share the same url) by setting the credentials property to same-origin. If the server is not on the same origin or the browser is not automatically appending this property, the cookie will not be sent.

The current version of Deep Chat does not have a manual way to set this. Hence I created a quick patch for the deep-chat-dev package version 9.0.64 where you can configure it. (This package behaves just like the normal one except it's a different name)

Now you should be able to set your config with credentials: 'same-origin':

:request="{
  url: 'http://localhost:8080/chat-stream-flowable',
  method: 'POST',
  credentials: 'same-origin',
  headers: { charset: 'utf-8' },
  additionalBodyProps: { field: 'value' }
}"

or try credentials: 'include':

:request="{
  url: 'http://localhost:8080/chat-stream-flowable',
  method: 'POST',
  credentials: 'include',
  headers: { charset: 'utf-8' },
  additionalBodyProps: { field: 'value' }
}"

Let me know if this helps.

OvidijusParsiunas commented 7 months ago

It is 3:00AM in the morning where I live, so I am going to bed and will be able to respond tomorrow afternoon. Thanks!

wysstartgo commented 7 months ago

okay,thanks for you answer,it has been sloved by add credentials: 'include'

OvidijusParsiunas commented 7 months ago

Good to hear. I will be releasing a new version of Deep Chat sometime this week and will include this feature in the new release. I will close this issue when this is done. Thanks!

OvidijusParsiunas commented 7 months ago

Hi. The functionality discussed above has now been released in Deep Chat version 1.4.4. Please read the release notes for more information.

I will be closing this issue, but if you experience any problems relating to credentials feel free to comment below or raise a new issue for anything else. Thanks!