content: Android Capacitor origin is `https://localhost` by default, not `http://localhost`
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 80/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- android
- Domain
- documentation
Research direction
Open the CORS troubleshooting page at the issue's URL and review the paragraph describing Capacitor origins. Update it to state that Android uses https://localhost by default, explain the server.androidScheme override, and confirm the wording matches the linked Capacitor configuration references.
Written by the indexing model from the issue text.
Description
URL
https://ionicframework.com/docs/troubleshooting/cors#what-is-cors
Issue Description
Summary
The CORS docs state that the Android origin is http://localhost. On current Capacitor this is https://localhost by default, because server.androidScheme defaults to https. The current wording leads people to whitelist the wrong origin and get blocked requests on Android.
What the docs say
From the CORS page:
An origin is the combination of the protocol, domain, and port from which your Ionic app or the external resource is served. For example, apps running in Capacitor have capacitor://localhost (iOS) or http://localhost (Android) as their origin.
What actually happens
On a default Capacitor app (no androidScheme set), the Android webview origin is https://localhost, not http://localhost.
Tested on Capacitor 7 with a production backend. The server logged the incoming Origin header per platform:
Android origin = https://localhost
iOS / iPadOS origin = capacitor://localhost
The CORS allowlist only started working on Android after adding https://localhost. Adding http://localhost had no effect.
Why
Since Capacitor 6 made https the default androidScheme, the default Android origin is https://localhost. Per the config reference, the origin is androidScheme + hostname. It is http://localhost only if you set androidScheme: 'http'. Also raised in #3639.
Suggested wording
Apps running in Capacitor have
capacitor://localhost(iOS) orhttps://localhost(Android) as their origin by default. The Android scheme followsserver.androidScheme, which defaults tohttps. It ishttp://localhostonly if you setandroidScheme: 'http'.
If this looks right, I am happy to open a PR with the change.
- Dominant language
- MDX
- Stars
- 621
- Forks
- 3.2k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 86
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ionic-team/ionic-docs
-
content
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
ionic-team/ionic-docs#4705 ·
-
content package: angular
Difficulty 2/5 Half a day Newbie friendliness 78/100
ionic-team/ionic-docs#4702 ·
-
content: broken link Opencontent
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ionic-team/ionic-docs#4381 · 2 comments ·
-
triage
Difficulty 1/5 Under an hour Newbie friendliness 72/100
ionic-team/ionic-docs#3639 ·
-
content package: angular
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ionic-team/ionic-docs#3583 ·
All issues in ionic-team/ionic-docs
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Ecosystem: ClawMetry — the Qwen Code reader is now free and open source (follow-up to #9294 / #9338) Opencategory/integration priority/P3 scope/documentation status/ready-for-human type/feature-request
Difficulty 1/5 Under an hour Newbie friendliness 84/100