Allow sending cookies on XMLHttpRequest.send()#44
Conversation
|
Thanks for the PR! I think this would be better as an opt-in feature—enabling withCredentials by default could cause unexpected issues (e.g., with CORS or CSRF). Could we make it configurable via patch_all(with_credentials=True) or something similar? |
|
To be able to test these changes, I had to do some fixes to the test suite. I wasn't able to run it as is on macOS 15.4.1 (Apple Silicon) with Chrome 136.0.7103.93. Still, some issues remain:
@koenvo Any thoughts? |
|
I was able to "fix" the failing tests from |
|
Since setting |
|
@koenvo Any thoughts on the present iteration of this PR? |
XMLHttpRequest.send()does not send any cookies that the browser may have for the requested URL unlesswithCredentials = True. This PRenables that flag by defaultallows setting that flag as an option.This allows doing requests to URLs that depend on cookie-based authentication (e.g. where the user authenticates in one browser tab/window, and the pyodide application is running in another tab/window).
I tested this by overriding the
pyodide_http._core.send()function in a Marimo WASM notebook, and then doing arequests.get()against an URL protected by Cloudflare Access (which uses cookies as one of the possible authentication methods). This is the code I used: