bug: document.cookie does not seem to work at all with capacitor/core http
See original GitHub issueBug Report
I may be going crazy, so if this isn’t functionality that is supposed to work, please let me know.
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 4.4.0
@capacitor/core: 4.4.0
@capacitor/android: 4.4.0
@capacitor/ios: 4.4.0
Installed Dependencies:
@capacitor/cli: 4.4.0
@capacitor/core: 4.4.0
@capacitor/android: 4.4.0
@capacitor/ios: 4.4.0
[success] iOS looking great! 👌
[success] Android looking great! 👌
Platform(s)
Current Behavior
Requesting any URL that replies with set-cookie
as a header seems to be ignored. document.cookie
continues to be undefined.
Expected Behavior
With CapacitorHttp and CapacitorCookie enabled, requesting a URL that has a set-cookie
should update document.cookie
and send cookies afterwards to further requests.
Code Reproduction
Clone the repo here: https://github.com/silviogutierrez/capacitor-http-tests
This is virtually the result of npm init @capacitor/app
but with these lines modified; https://github.com/silviogutierrez/capacitor-http-tests/blob/main/src/js/capacitor-welcome.js#L83
Run: npm install npm run build npx cap sync ios npx cap sync android npx open android npx open ios
Then run both projects. Click “make request” and see how the console logs cookies, and they continue to be undefined. Just in case it was an async thing, click “log cookies” a bit later to continue observing the behavior.
Note the curl for the URL being hit produces this (note the set-cookie header)
curl -X GET -I https://www.joyhealthtracker.dev/api/csrf/
HTTP/2 200
server: openresty/1.15.8.2
date: Thu, 27 Oct 2022 02:55:46 GMT
content-type: application/json
content-length: 2
strict-transport-security: max-age=15724800; includeSubDomains
vary: Cookie, Origin
x-frame-options: DENY
x-api-version: v13.0.0
set-cookie: csrftoken=vK5Kbn4cx4L2rGjKsw84QbMN6Blk5eq1yl378tLhQLnoKvkS2bt4up6wDRYd4fSC; expires=Thu, 26 Oct 2023 02:55:46 GMT; Max-Age=31449600; Path=/; SameSite=Lax
x-request-id: 1000f65fb8b46700f9bff000daf1be90
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top GitHub Comments
@ItsChaceD then you can close this one right?
I have to do something like this to make
document.cookies
not be undefined, but i thought it might have worked otherwise. I"m not sure thoughI’m not sure if both mods were required. I filed a bug somewhere about this, but I can’t seem to find it. I wonder if i failed to submit it properly 😦