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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: CapactorHttp does not pass Authorization header on iOS #6213

Closed
amoscardino opened this issue Jan 13, 2023 · 3 comments
Closed

bug: CapactorHttp does not pass Authorization header on iOS #6213

amoscardino opened this issue Jan 13, 2023 · 3 comments
Labels
needs reproduction needs reproducible example to illustrate the issue platform: ios

Comments

@amoscardino
Copy link

amoscardino commented Jan 13, 2023

Bug Report

Capacitor Version

馃拪   Capacitor Doctor  馃拪 

Latest Dependencies:

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

Installed Dependencies:

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

[success] iOS looking great! 馃憣

Platform(s)

  • iOS

Current Behavior

Making an HTTP request with CapacitorHttp and including an Authorization header results in the actual request to the server missing the header.

Expected Behavior

All headers passed to CapacitorHttp should be passed to the server.

Code Reproduction

I'm not sure how to set up a full replication of this since it requires a server app in addition to the client app. The client code is simple:

const response = await CapacitorHttp.get({
    url: 'https://my.server.domain/api/something'
    headers: {
        'Authorization': `Token MyToken12345`
    }
});

The behavior is the same when using fetch() with the plugin enabled to intercept those requests, too.

Other Technical Details

npm --version output: 8.19.1

node --version output: v16.13.2

pod --version output (iOS issues only): 1.10.1

Additional Context

I asked about this issue on the Ionic Forums here.

After some digging into the Capacitor code, I think the issue is related to URLRequest and how it treats certain headers. Per Apple's documentation, certain headers are reserved and setting them will do nothing. Authorization is one of those headers but there's no other way to pass that header when using CapacitorHttp.

@ionitron-bot ionitron-bot bot added the triage label Jan 13, 2023
@ionitron-bot ionitron-bot bot removed the triage label Jan 13, 2023
@jcesarmobile jcesarmobile added the needs reproduction needs reproducible example to illustrate the issue label Jan 17, 2023
@Ionitron
Copy link
Collaborator

This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.

Please see the Contributing Guide for how to create a Code Reproduction.

Thanks!
Ionitron 馃挋

@Ionitron Ionitron added the needs reply needs reply from the user label Jan 17, 2023
@amoscardino
Copy link
Author

Apparently this is not a bug but a (really) bad error message from the API I'm trying to interact with. Closing now.

@Ionitron Ionitron removed the needs reply needs reply from the user label Jan 17, 2023
@ionitron-bot
Copy link

ionitron-bot bot commented Feb 16, 2023

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 Feb 16, 2023
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: ios
Projects
None yet
Development

No branches or pull requests

3 participants