Skip to content
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

[Bug]: duplicate HTTP header Cookie #7221

Closed
1 of 3 tasks
ermolaev opened this issue Jan 29, 2024 · 12 comments
Closed
1 of 3 tasks

[Bug]: duplicate HTTP header Cookie #7221

ermolaev opened this issue Jan 29, 2024 · 12 comments
Labels
needs reproduction needs reproducible example to illustrate the issue platform: android

Comments

@ermolaev
Copy link

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 5.6.0
@capacitor/core: 5.6.0
@capacitor/android: 5.6.0
@capacitor/ios: 5.6.0

Installed Dependencies:

@capacitor/cli: 5.6.0
@capacitor/core: 5.6.0
@capacitor/ios: 5.6.0
@capacitor/android: 5.6.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

Other API Details

node --version
v20.10.0

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

duplicate HTTP header Cookie

Expected Behavior

single HTTP header Cookie

Project Reproduction

.

Additional Information

const config: CapacitorConfig = {
  appId: 'com.test.test',
  appName: 'test',
  webDir: 'www',
  server: {
    allowNavigation: ['https://54cf-80-246-81-186.ngrok-free.app'],
    cleartext: true
  }
}

image

Copy link

ionitron-bot bot commented Jan 31, 2024

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed.
Please see the Contributing Guide for how to create a Sample App.
Thanks! Ionitron 💙

@Ionitron Ionitron added needs reply needs reply from the user and removed needs reply needs reply from the user labels Jan 31, 2024
@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Feb 1, 2024
@ermolaev
Copy link
Author

ermolaev commented Feb 5, 2024

@Ionitron Ionitron removed the needs reply needs reply from the user label Feb 5, 2024
@jcesarmobile
Copy link
Member

The sample app doesn't seem to be complete, the index.html that is loaded from ngrok doesn't do anything and the capacitor app just redirects to that file, I don't see any cookies set or on the headers, can you review the sample app and make the needed changes to make sure the issue can be reproduced?

@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Feb 13, 2024
@ermolaev
Copy link
Author

ngrok set cookie in first visit

on next runs app, capacitor will be duplicate cookie header

example app really very simple, but reproduce bug

insted ngrok and static index.html you can use http server, but http server, may have its own logic for processing double headers, Rails for example, combines them into one header, but separates them with a comma

Cookie: a=1
Cookie: a=1

in rails convert to Cookie: a=1, a=1

@Ionitron Ionitron removed the needs reply needs reply from the user label Feb 13, 2024
@jcesarmobile
Copy link
Member

I ran ngrok with the command the README said and there are no ngrok cookies, not on the header as your images show, nor on the Cookies of the Application section of Chrome dev tools.

@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Feb 13, 2024
@ermolaev
Copy link
Author

recording video https://disk.yandex.ru/d/cyjJmaS2Kn5RbA

@Ionitron Ionitron removed the needs reply needs reply from the user label Feb 13, 2024
@jcesarmobile
Copy link
Member

I did that, but looks like the cookie is being set on the "you are about to visit xxx" screen, which in my case doesn't appear.
I'm using ngrok 3.6.0 just installed it from homebrew and it's a free account (saying this since the message says you should use a paid acount to get rid of the screen), so not sure why I don't get that screen, but I can't reproduce.

@ermolaev
Copy link
Author

I updated repo ermolaev/cap-cookie-problem@ef281fb

press to button REFRESH in emulator

cookie user=John should sending
image

@jcesarmobile
Copy link
Member

thanks for the update, I could reproduce now

the issue if fixed in Capacitor 6 (it's in RC state) since this was caused by the way the javascript was injected using a native connection and in Capacitor 6 it's injected in a different way, so the issue is not present, but the change can't be backported to Capacitor 5, so your only solution is to move to Capacitor 6 despite it's still RC or wait for the final release in a few weeks

@ermolaev
Copy link
Author

I checked 6.0.0-rc.0, problem is not reproduce 👍

@jcesarmobile can you show the commit that solved this problem, I want to explore it)

@jcesarmobile
Copy link
Member

It was this one #7199 but because this one was done first #7135

Capacitor 5 injects javascript by reading the html files and appending the javascript code in the <head> tag, and in Capacitor 6 it uses a new API that google added that injects the javascript into the WebView itself, so no file manipulation is needed and solved several issues that were caused by that.

Copy link

ionitron-bot bot commented Mar 15, 2024

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs reproduction needs reproducible example to illustrate the issue platform: android
Projects
None yet
Development

No branches or pull requests

4 participants