You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2022/11/29 04:39:46 UTC

[GitHub] [cordova-android] breautek commented on issue #1520: How to manage reload on cordova-android 10+

breautek commented on issue #1520:
URL: https://github.com/apache/cordova-android/issues/1520#issuecomment-1330068727

   As I've already explained in your other comment thread.
   
   Reloading `https://localhost` **does** work (it will reload the index file, providing one exists). However using the history API features to build "ordinary" URLs and then attempting to reload them **will not** work because there is no underlying file to reload from disk.
   
   The browser reload API expects a physical file to be found on disk to load from, so if you have a login page for example at `/login` but there is no file called `login` in your `www` folder, the browser will reach a file not found error, even if you can naturally navigate to the page from within your application. This is **standard** browser behaviour.
   
   > Is there some kind of rewrite url engine ?
   
   No, again as I explained, there is no underlying webserver in Cordova apps, there is simply the filesystem. Android webview apis offers features that makes it **appear** there is a webserver (e.g. loading from `https://...`) but it is a facade. Cordova does not implement any URL rewrite or routing. `https://localhost` is relative to your `www` directory.
   
   > What should be the best solution to manage reload now ?
   
   Do not use the history API strategy to push fake URLs. Instead use a hash-based strategy for client side routing for your SPA apps instead. These URLs aren't visible to your user like a typical browser, there is no address bar. This way, the browser loaded documented is always your HTML document file, generally your `index.html` file, which is the file that will get reloaded when calling `window.location.reload`. The hash information, which contains your routing path will be retained so your router library should render the proper UI.
   
   If you're using web frameworks like Angular, their routing might be using the History API by default as they are tailored for traditional web development. So you might need to look for additional configuration options to make it use hash-based routing instead.
   
   I'm closing this because it's not a bug. If you have further questions on this matter, Apache has recently enabled [Discussions](https://github.com/apache/cordova/discussions) which will be a more appropriate place for QA style posts.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org