[Bug]: Android does not inject the Capacitor bridge after navigating to an allowNavigation URL
Los mantenedores suelen responder en 1 día
@eric-horodyski ya está trabajando en esto.
Desde el 22/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 38/100
Línea de trabajo
The relevant code is in Bridge.java under android/capacitor/src/main/java/com/getcapacitor/, in loadWebView(), where the document-start script is registered for only the appUrl origin, while the allowNavigation origins are already collected in allowedOriginRules. Reproduce with the linked redirect project, then check whether plugins work on the remote page. Pull request #8429 already contains the proposed change and has no maintainer review, so check it before starting new work. Done means the bridge is injected on allowNavigation origins on Android and the existing Android tests still pass.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 8.5.3
@capacitor/core: 8.5.3
@capacitor/android: 8.5.3
@capacitor/ios: 8.5.3
Installed Dependencies:
@capacitor/cli: 8.5.3
@capacitor/core: 8.5.3
@capacitor/android: 8.5.3
@capacitor/ios: 8.5.3
[success] iOS looking great! 👌
[success] Android looking great! 👌
Other API Details
Platforms Affected
- iOS
- Android
- Web
Current Behavior
On Android, the app starts on the local origin (https://localhost) and then navigates with window.location to a remote URL listed in server.allowNavigation (for example https://client.example.com).
allowNavigation keeps the navigation inside the WebView, but native plugins stop working on the remote page. Calls fail with UNIMPLEMENTED / "plugin is not implemented on android". window.Capacitor.PluginHeaders is empty on the new origin.
Cause: Bridge.loadWebView() registers the bridge with WebViewCompat.addDocumentStartJavaScript only for the appUrl origin:
WebViewCompat.addDocumentStartJavaScript(webView, injector.getScriptString(), Collections.singleton(allowedOrigin));
allowedOrigin is derived from appUrl (https://localhost). The allowNavigation origins are already collected in allowedOriginRules, but that set is not passed to addDocumentStartJavaScript.
iOS does not have this problem. WKUserScript is injected at document start on every main-frame load, with no origin filter, so plugins keep working after the same redirect.
This is still the case in the 8.5.3 tag, and also in 9.0.0-alpha.8:
https://github.com/ionic-team/capacitor/blob/8.5.3/android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Expected Behavior
After navigating to a URL allowed by server.allowNavigation, Android should keep the native bridge, same as iOS.
addDocumentStartJavaScript should receive allowedOriginRules (local origin, server.url when set, and allowNavigation origins), not only the appUrl origin. Plugins should keep working on the remote page without an app-level patch of Bridge.java.
Project Reproduction
https://github.com/Dylancyclone/capacitor-android-redirect
Additional Information
Same bug as #7454, still open. The reproduction repo linked above is the one from that issue. The one-line fix is already in #8429 (rebased from #7571) and has had no maintainer review. #7571 was closed for backlog rebase, not because the change was rejected.
Please land #8429, or apply the same change on main:
-
WebViewCompat.addDocumentStartJavaScript(webView, injector.getScriptString(), Collections.singleton(allowedOrigin));
-
WebViewCompat.addDocumentStartJavaScript(webView, injector.getScriptString(), allowedOriginRules);
Reproduced on 8.5.3. The same line is still present in 9.0.0-alpha.8. Apps currently have to patch @capacitor/android themselves to get iOS parity.
- Lenguaje dominante
- TypeScript
- Estrellas
- 17.1k
- Forks
- 1.3k
- Merge medio
- 1 d 22 h
- PR fusionados (30 d)
- 26
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ionic-team/capacitor
-
triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ionic-team/capacitor#8759 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Plugin call after navigation can be answered before reply proxy is updatedPosiblemente ocupada @MateStrysewske la tomó hace 71 días. Abiertotriage
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
ionic-team/capacitor#8616 ·
Los mantenedores suelen responder en 1 día
-
help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ionic-team/capacitor#8574 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
SystemBars: safe area CSS injection throws "Cannot read properties of null" on startup (Android 16)Posiblemente ocupada @kttalley la tomó hace 62 días. Abiertotriage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ionic-team/capacitor#8530 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
fix(android): remove unchecked Java compilation warningsPosiblemente ocupada @Ajamuar la tomó hace 15 días. Abiertotriage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ionic-team/capacitor#8529 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de ionic-team/capacitor
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
prio:low scope:world
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
OliverRomhagen/vrigstad-joyride#849 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
genfeedai/genfeed.ai#11916 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
erkamyaman/rust-anything#1153 ·
Los mantenedores suelen responder en 1 día
-
The Phase 5 report says 0.3.0 waits for the live checkPosiblemente ocupada @fzn0x la tomó hoy. Abiertodocumentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día