grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.55k stars 762 forks source link

WithCredentials not work #1202

Open iamjbw opened 2 years ago

iamjbw commented 2 years ago

when I set this new TestService(url null, {withCredentials: true}), but it seems not work for me. cookie did not send with request

sampajano commented 2 years ago

Thanks for report :)

As far as i could tell, we're correctly passing along option as the withCredentials attribute on the XHR: https://github.com/grpc/grpc-web/blob/ce7d734e8a1a7d1f09fd6bdb23299f3ef7447887/javascript/net/grpc/web/grpcwebclientbase.js#L188

Could you provide more details on how exactly is your setup (e.g. domain names) and what are you expecting?

Thanks :)

iamjbw commented 2 years ago

image image image image

version: 1.3.1

It seems withCredentials not work, cookie did not send

sampajano commented 2 years ago

Thanks for the additional info :)

From my local testing using the echo server, withCredentials: true will fail CORS check due to Access-Control-Allow-Credentials is not set on the test server. (Which proves that the flag is taking effect.) If i also set suppressCorsPreflight: true, then i can see the cookie being attached.

Could you provide full information on all the requests/responses that you observed?

Thanks :)