-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
If hostname set, cannot navigate certain app's url - it tries to open the remote one #1428
Comments
Successfully reproduced in an API 30 emulator. I think the intended behaviour is if If it doesn't, a standard 404 should be present I think. |
It is a very archaic approach, modern Web applications are often Single-Page Applications, with only one page (e.g. So it is better to open any URLs correctly (or add a special option on behaviour) |
That specifically is a problem that Cordova won't solve. I agree that the domain that is set for the WbebViewAssetLoader should be captured and not attempt to load in the systems web browser, that's definitely a bug. But Cordova will not do any other rerouting or redirecting of paths to another file. It won't be a router in that sense. For client side routing in single page applications, I'd suggest using a hash-based routing strategy on Cordova apps So if |
Not router... Please just add preference: if
It is definitely obsolete in 2022 year. If you do not want to learn modern approaches in 2022 year - let's just close that issue at all... I will develop my own plugin (or some other architecture) which will solve the problem... |
What is the actual use case for having clean URLs in a cordova application where URLs are never shown to the user? |
@breautek we are developing hybrid applications, which can work both in Web browser (on PC), and as Cordova application. Also, we are using different JS libraries which are better supporting HTML5 History API (clean URLs) than hashes. Hashes are just unfamiliar for any web developer in current decade. |
For Cordova specific frameworks we have Ionic / Angular / React (Framework for Cordova) uses hash based routing by default. For non-cordova specific frameworks we have the common: react-router that provides a Hash strategy. It does state it shouldn't be used unless necessary because they are thinking in the context of where URLs are seen in traditional web applications, where unclean URLs effects SEO. It doesn't have a default routing strategy, you have to declare it. I'm less familiar with svelte but one of the recommended packages I saw was svelte-spa-router which uses hash based routing by default.
So I don't really think has it's place. Hashes are definitely obsolete for traditional web development, especially for any system that is sensitive to SEO, which Cordova applications are not. Part of my push-back is because this was something that was discussed previously in #1137 Adding the flag as suggested to redirect to the html file on not found files I think would fall into the same category.
If you truely need clean URLs for your cordova application, then this would be your path forward. But I've already listed above that all modern frameworks have a hash-based strategy available, either built-in, or as a third-party library. Abstractions can easily be made so that the cordova applications uses hash-based routing while your web portal uses clean urls. If you think Cordova should reconsider this stance, then I'd suggest opening a thread on our Dev Mailing List, so other project members can pitch in. |
Bug Report
Problem
I set
preference name="hostname" value="site.com" />
and I trying to navigateWhat is expected to happen?
should open corresponding application URL.
And:
should open corresponding application URL, too.
What does actually happen?
First one works, but second one doesn't. It tries to open remote URL with same host. And, it opens that URL in Cordova's webview, not in external browser...
Information
Command or Code
See above.
Environment, Platform, Device
Android.
Version information
cordova 11.0.0
cordova-android 10.1.2
Checklist
The text was updated successfully, but these errors were encountered: