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

[Feature]: Allow setting global headers for Capacitor Http #7432

Open
2 of 3 tasks
bosh-code opened this issue Apr 26, 2024 · 0 comments
Open
2 of 3 tasks

[Feature]: Allow setting global headers for Capacitor Http #7432

bosh-code opened this issue Apr 26, 2024 · 0 comments
Labels

Comments

@bosh-code
Copy link
Contributor

Description

Add a section in the capactitor config for headers to be used by the capacitor Http plugin, similar to User Agent config.

Platforms

  • iOS
  • Android
  • Web

Request or proposed solution

I'm happy to do the changes for it if it something the maintainers would like to implement. I'm suggesting it as we have had to do it at work so requests to one of our APIs work.

In the capacitor configuration, something like this:

...
 plugins: {
    CapacitorHttp: {
      enabled: true,
      customHeaders: {
        Origin: 'example.com'
        ...
    },
...

Then in native-bridge:

convertBody(body).then(({ data, type, headers }) => {
  // Example based on the patch I wrote for our app:
  otherheaders = {
    ...customHeaders, // From cap config
    ...otherHeaders
  }
  ...

Alternatives

No response

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant