Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($location): support alternative means of setting application base path #6129

Closed
wants to merge 1 commit into from

Conversation

caitp
Copy link
Contributor

@caitp caitp commented Feb 5, 2014

In HTML, the <base> tag is used to configure how relative hyperlinks are resolved. In Angular, it has another use, configuring how URLs are rewritten. Because of this, setting the base URL to some external path outside of the application would cause $location.$$parse() to throw (which is the desired behaviour).

This change enables developers to imperatively configure the application basePath, taking advantage of the natural HTML use of the tag without breaking Angular applications.

Example:

angular.module("test", [])
 .config(function($locationProvider) {
   $locationProvider.baseHref("http://foo.com/the/base/application/path/");
 });

Closes #4442

… path

In HTML, the <base> tag is used to configure how relative hyperlinks are resolved. In Angular, it
has another use, configuring how URLs are rewritten. Because of this, setting the base URL to some
external path outside of the application would cause $location.$$parse() to throw (which is the
desired behaviour).

This change enables developers to imperatively configure the application basePath, taking advantage
of the natural HTML use of the <base> tag without breaking Angular applications.

Example:

```
angular.module("test", [])
  .config(function($locationProvider) {
    $locationProvider.baseHref("http://foo.com/the/base/application/path/");
  });
```

Closes angular#4442
@IgorMinar
Copy link
Contributor

please see #3102 and #2805

this problem is much more complicated IMO and $locationProvider.baseHref is not a desirable solution.

@IgorMinar IgorMinar added this to the Purgatory milestone Feb 10, 2014
@caitp
Copy link
Contributor Author

caitp commented Feb 10, 2014

I'm not sure that it's much more complicated, but I see your point that a directive for specifying the app root url would be simpler. I think most of the extended problems mentioned on those issues are sort of unrelated, or tangentially related at best. What this really comes down to is how URLs are resolved, by the browser and by $location.

N'either of those issues seem to be PRs implementing the declarative solution, though.

@caitp caitp closed this Apr 17, 2014
@thomasofdenmark
Copy link

+1

1 similar comment
@soluml
Copy link

soluml commented May 13, 2015

+1

@ChadKillingsworth
Copy link

Base tags break SVG icons in FireFox. Without an officially documented way to set the baseHref of an application, we are left with either dropping support for browsers without history.pushState or decorating an internal, undocumented angular core service $browser.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

angular ngRoute breaks when using base tag
9 participants