there. I using getStream chat service in React web app and i noticed one thing. After changing a channel i have two response from server one 201 and another 200.
201-xhr
and
200-Preflight
Sometimes i may have only one 201-xhr
I was wondering could it be the issue on my app, that i make two calls or it's normal?
CodePudding user response:
An HTTP request only has one response.
Your code is requesting once, but HTTP-wise, two requests are sent (giving you a total of two responses).
This happens because there's an initial request (preflight) which is done behind the scenes by the browser just to check if the CORS protocol is understood and if the server will allow your request.
You can see more details here.
Once the browser knows about the CORS options, it might decide not to request them for a while (which is why sometimes you see only 1 request/response in the network inspector).