-
Notifications
You must be signed in to change notification settings - Fork 17
Allow sending cookies on XMLHttpRequest.send() #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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 |
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: