Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Absolute (root relative) paths do not resolve to www folder, instead point to C:\... #398

@FEA5T

Description

@FEA5T

Bug Report

Absolute (root relative) paths do not resolve to www folder, instead point to C:... causing failed requests in the webapp.

Problem

Webapps that run normally on a webserver cannot be ported over to cordova because all absolute (root relative) paths fail.

What is expected to happen?

Absolute (root relative) paths should resolve to www folder which is consistent across iOS, android, windows, etc rather than pointing to an inconsistent drive root where the path differs.

What does actually happen?

Absolute (root relative) paths in your web app resolve to the drive root causing requests to fail that would succeed in any other server environment.

Information

Cordova behaves inconsistently and breaks a core principle of its own product: that you should be able to package and run a web app without rewriting it natively.

Command or Code

All absolute (root relative) paths in html and JS UI code should resolve to the www folder. At a bare minimum there should be a configuration as to where these paths point, so that the www folder can be targeted. There are many reasons for this:

  1. Consistency: an app that runs in browser off a webserver should be portable to cordova with minimal changes.
  2. Sandboxing: a web UI should not be concerned with, or be knowledgeable of a devices root drives and folder structure, instead it should only be knowledgeable of it's own root application folder.
  3. SPA necessity: Relative paths do not work in a modern web UI with a router (take for example react or a vue app with vue-router): often times the route that the application is at will change, invalidating relative paths inside reusable component code. If a component relies on path "components/tabs.vue" and the browser is at path "www.mydomain.com/" the component will load, but if the browser is at "www.mydomain.com/movies/1234" then it will try to load "www.mydomain.com/movies/1234/components/tabs.vue" which will fail. Absolute (root relative) paths are necessary to prevent these errors and cordova should respect standards and point absolute paths at the www root folder.

Environment, Platform, Device

On all environments/devices.

There are many questions/complaints about this behavior and there is no known workaround, only suggestions to use relative paths (which do not work/are not compatible with SPA routers).

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions