content: Android Capacitor origin is `https://localhost` by default, not `http://localhost`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 80/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- android
- Lĩnh vực
- documentation
Hướng nghiên cứu
Mở trang khắc phục sự cố CORS tại URL của issue và xem lại đoạn mô tả các origin của Capacitor. Cập nhật đoạn này để nêu rằng Android sử dụng https://localhost theo mặc định, giải thích việc ghi đè bằng server.androidScheme và xác nhận rằng cách diễn đạt khớp với các tài liệu tham chiếu cấu hình Capacitor được liên kết.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- MDX
- Star
- 621
- Fork
- 3.2k
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 86
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ionic-team/ionic-docs
-
content
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
ionic-team/ionic-docs#4705 ·
-
content package: angular
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 78/100
ionic-team/ionic-docs#4702 ·
-
content: broken link Đang mởcontent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ionic-team/ionic-docs#4381 · 2 bình luận ·
-
triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
ionic-team/ionic-docs#3639 ·
-
content package: angular
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
ionic-team/ionic-docs#3583 ·
Tất cả issue của ionic-team/ionic-docs
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
agilepathway/label-checker#640 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
BasedHardware/omi#15662 · 1 bình luận ·
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Docs are out of date: README structure tree, "Make It Yours" pointer, CONTRIBUTING test notes Đang mởdocumentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
amponce/archive-movie-browser#167 ·
-
user-reported
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Kong/developer.konghq.com#7316 ·