capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

bug: external link opens in webview instead of browser

Open umeshn1 opened this issue 3 years ago • 0 comments

Bug Report

Capacitor Version

Capacitor Doctor   

Latest Dependencies:       

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

Installed Dependencies:    

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

[success] Android looking great! 👌

Platform(s)

Tested on Android, not sure about IOS

Current Behavior

Any link that contains the hostname specified in capacitor.config.json opens in webview instead of external browser. Same behaviour with window.open and window.location

capacitor.config.json

"server": {
    "hostname": "example.com",
    "androidScheme": "https"
  },

https://user-images.githubusercontent.com/53205290/180592532-f6f996a6-b3ec-46b7-9156-7587be6b1112.mp4

Code Reproduction

https://github.com/umeshn1/external-link-bug npm run build && npx cap sync && npx cap open android

umeshn1 avatar Jul 23 '22 06:07 umeshn1

I think is by design to work like this so basically is not a bug but a feature :) Let me explain; The scope of the hostname field is to test your app in live reload execution. This means that whatever url put you there, it will simulate the app meaning will show in the webview so no browser will be open as it does not make sense. If you leave that to localhost, than the example.com will be opened in the browser as you are expecting...

albgen avatar Sep 01 '22 22:09 albgen

This is a confirmed bug. The hostname is not used for live reload, for live reload you use the url field. Also the problem is the url containing the hostname, not loading the actual hostname url, in the example the problem is the app navigating to google while the hostname is example.com

jcesarmobile avatar Sep 02 '22 09:09 jcesarmobile

Hostname can be anything, even example.com so you cannot prohibit that.

albgen avatar Sep 02 '22 10:09 albgen

Yeah, you are right about that, but the issue has nothing to do with what you are talking about. The issue is about the page navigating to google.com, not about navigating to example.com.

jcesarmobile avatar Sep 02 '22 11:09 jcesarmobile