You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
@fullName $location in HTML5 mode requires a <base> tag to be present!
4
+
@description
5
+
6
+
If you configure {@link ng.$location `$location`} to use
7
+
{@ng.provider.$locationProvider `html5Mode`} (`history.pushState`), you need to specify the base URL for the application with a [`<base href="">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) tag.
8
+
9
+
The base URL is then used to resolve all relative URLs throughout the application regardless of the
10
+
entry point into the app.
11
+
12
+
If you are deploying your app into the root context (e.g. `https://myapp.com/`), set the base URL to `/`:
13
+
14
+
```html
15
+
<head>
16
+
<base href="/">
17
+
...
18
+
</head>
19
+
```
20
+
21
+
If you are deploying your app into a sub-context (e.g. `https://myapp.com/subapp/`), set the base URL to the
22
+
URL of the subcontext:
23
+
24
+
```html
25
+
<head>
26
+
<base href="/myapp">
27
+
...
28
+
</head>
29
+
```
30
+
31
+
Before Angular 1.3 we didn't have this hard requirement and it was easy to write apps that worked
32
+
when deployed in the root context but were broken when moved to a sub-context because in the
33
+
sub-context all absolute urls would resolve to the root context of the app. To prevent this,
34
+
use relative URLs throughout your app:
35
+
36
+
```html
37
+
<!-- wrong: -->
38
+
<a href="/userProfile">User Profile</a>
39
+
40
+
41
+
<!-- correct: -->
42
+
<a href="userProfile">User Profile</a>
43
+
44
+
```
45
+
46
+
Additionally, if you want to support [browsers that don't have the `history.pushState`
47
+
API](http://caniuse.com/#feat=history), the fallback mechanism provided by `$location`
48
+
won't work well without specifying the base url of the application.
49
+
50
+
In order to make it easier to migrate from hashbang mode to html5 mode, we require that the base
51
+
URL is always specified when `$location`'s `html5mode` is enabled.
0 commit comments