does anyone know how to make this happen in ktor c...
# javascript
n
does anyone know how to make this happen in ktor client ?
Copy code
fetch('<http://another.com>', {
  credentials: "include"
});
or what things to do, headers to set ?
j
that is an old bug I had reported and they haven't fixed https://github.com/ktorio/ktor/issues/1187 . Finally I decided to use fetch directly.
n
i could maybe use headers instead.. but websockets on JS cannot pass extra headers along either, so either way its broken
b
cc @leonid
n
otherwise i am not even sure what can be done by ktor atm and how many of these calls i would have to refactor to expect/actual calls as mentioned i am doing al ogin call and then authenticated calls wherei pass the sessionId along and opening a websocket, also using the sessionId i have considered sending the sessionId as the first frame in the websocket, but it seems impossible to access the
Session
feature from outside on the ktor server, so i would have to reimplement the feature completely and handle it manually in ALL routes 😕
i forked ktor and added
authentication: $authentication
.. this works partially only.. it seems to get the cookie, it appears in the vchrome debugger at least, but following requests do not use it
this is that changes basically.. ugly but it does something.. https://github.com/NikkyAI/ktor/commit/cebc83268bfd7deee9f039c29b834f0a30783f3d
tried printing out
setCookie()
of the response and i guessi still do not get cookies
in the end i fixed it by exposing headers, managing them manually on the client and not using Ktor Sessions, instead rolling my own solution where the websocket can send the sessionId as first message and i can verify manually
s
This thread is pretty old. Does anybody have more recent info on how to set
credentials: include
on a JS client?
k
I'm using this, you can expand on it to handle errors better. I have the oauth2 token as a parameter so I can use it as a state in my components. Hope it helps