FEA5T commented on issue #398: URL: https://github.com/apache/cordova-windows/issues/398#issuecomment-951458388
First of all thank you for such a detailed response. It does however leave me with even more questions: > Cordova is just a packaging tool, it doesn't really implement any URL loading scheme Relative url's are translated to reference the 'www' folder, the path "/" is translated to return '/index.html', 'http://' is translated to 'file://' schema, and absolute url's do prefix a drive letter...so from this I assume there is some url translation going on somewhere by something, so I am wondering: 1) is it cordova that is handling this transformation, or some dependency, and if so, where is it happening, and is this code cross-platform or unique code to each platform? It seems to me this is the point where I would need to make necessary modifications so that cordova can behave consistently with a webserver. > It's standard browser behaviour (including in traditional web server apps) that if you have a url prefixed with with a forward slash (/) then the URL should be treated as an absolute URL. We cannot change what the "root" directory is. While this is true, my point is that: Absolute URL's typically point towards: the **application** root (not the devices root) - (as all webservers do) Relative URL's typically point towards: the **application** root (with the browser path appended). I am not suggesting to change the root directory of the process, simply translate absolute URL's the way relative URL's are translated today (without appending browser path): to reference the 'www' folder. This circles back to my question above, how/who/where is the translation happening? > I don't think Cordova claims at any point that you can package up any web app without rewriting it. Cordova does claim that you can package up web apps so that you can deploy native apps with the majority of your app code being ran in the system provided webview, then deploy it via different platforms using largely the same codebase. It does not mean you can take any traditional web application hosted on a web server and package it up and it will work as is. There are differences between traditional web hosted environments and native apps with embedded web content. I am a bit puzzled by this. I don't mean to come off as rude, I do appreciate your perspective, however, cordova's main use case is packaging web apps into cross platform native apps. It seems to me the core functionality here is loading html/js/css from a device directly and rendering it in a webview. Obviously there are environmental differences such as how api calls are made or advanced browser api's that may differ, but (ignoring routing) why is the most core functionality (loading an html file with 1 image) not consistent with the browser and the way web apps are served? When I drop my codebase into cordova, basic file references break because they are absolute (which half the internet is built on). I am truly baffled because this is the most basic functionality cordova offers, and honestly, maybe I am naïve here, but this seems like a major oversight in design/principles (not valuing consistency and simplicity). It is not a good look for cordova when I drop in a basic app and it wont run because of file references that do work in every major browser (without routing). Is there a valid use case for accessing the device root when the folder structure isn't consistent cross-platform? > SPA does work in Cordova environments. but for routing you can't use "clean urls" which is often sought after in traditional web development for the purposes of clean looking URLS in the address bar and/or SEO purposes. In Cordova environments you have to use hash-based routing, because there is no intermediate web server that sits between your web app your source files that can be used to manipulate the routing. I also ran into this issue. This is another area where route translation and file response handling would allow clean URL routing, and again just comes down to what layer of the code is handling routes and performing file reads and returning files to the webview. Is there a cross platform piece of code on the device side that is handling url requests and determining which file to load (or ask the device api to read the file)? If so, what is that entry point? Lastly, do you know of any plugins/competing technologies that may handle route translation on the device side? Seems to me this would easily enable absolute refs + clean urls + possibly api proxying as well. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
