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]: CapacitorHttp removing query params when using native fetch #7319

Closed
1 of 3 tasks
marcelobotega opened this issue Mar 7, 2024 · 6 comments · Fixed by #7329
Closed
1 of 3 tasks

[Bug]: CapacitorHttp removing query params when using native fetch #7319

marcelobotega opened this issue Mar 7, 2024 · 6 comments · Fixed by #7329
Labels
plugin: http type: bug A confirmed bug report

Comments

@marcelobotega
Copy link

marcelobotega commented Mar 7, 2024

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

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

Installed Dependencies:

@capacitor/ios: not installed
@capacitor/cli: 5.7.2
@capacitor/android: 5.7.2
@capacitor/core: 5.7.2

[success] Android looking great! 👌

Other API Details

❯ npm --version
10.2.4

❯ pnpm --version
8.15.1

❯ node --version
v20.11.1

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

Since @capacitor/[email protected] when calling an API using the browser fetch with CapacitorHttp enabled, the interceptor is removing the query params.
CapacitorHttp.get works normally.

Expected Behavior

The query params should not be removed from the URL

Project Reproduction

https://github.com/marcelobotega/capacitor-http-error

Additional Information

The instructions for the reproduction repo are on the readme.
The problem do not happen on @capacitor/[email protected] you can downgrade the version on package.json and the API calls will have the query params.
The placeholder API will work, but the ?postId=2 params will not be on the URL on version >= 5.7.1

@colbymelvin
Copy link

colbymelvin commented Mar 7, 2024

Seeing this also (on iOS and Android), I believe it was introduced here.

Specifically, that change appears to be constructing a proxy URL in order to send a request through the appropriate CapacitorHttp interceptor. However, it's only using the pathname property from the original URL object to construct the proxy URL. Notably pathname will exclude an existing query string.

@booleanbetrayal
Copy link

This seems like a major regression that could lead to lots of application breakage.

@patrickjquinn
Copy link

patrickjquinn commented Mar 11, 2024

This has entirely broken my project as I'm sure it has for many. This should be considered a sev1 regression IMO. It also impacts iOS too FYI.

@jcesarmobile jcesarmobile added the type: bug A confirmed bug report label Mar 11, 2024
Copy link

ionitron-bot bot commented Mar 11, 2024

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.

@ciekawy
Copy link
Contributor

ciekawy commented Mar 19, 2024

I did try 5.7.3 and now I'm getting Failed to load resource: Could not connect to the server.

and the url instead of
https://<host>/<path>?<queryparams>
is:
https://localhost/_capacitor_https_interceptor_/<host>/<path>?<queryparams>

Copy link

ionitron-bot bot commented Apr 18, 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 Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
plugin: http type: bug A confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants