This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 1 file changed +51
-0
lines changed
docs/content/error/$location
1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ @ngdoc error
2
+ @name $location:nobase
3
+ @fullName $location in HTML5 mode requires a <base> tag to be present!
4
+ @description
5
+
6
+ When {@link ng.$location `$location`} service is configured to use the
7
+ {@ng.provider.$locationProvider `html5Mode`} (`history.pushState`), it is required that the base URL
8
+ is specificed for the application via `<base href="">` tag.
9
+
10
+ The base URL is then used to resolve all relative urls throughout the application regardless of the
11
+ entry point into the app.
12
+
13
+ If you are deploying your app into the root context, set the base url to `/`:
14
+
15
+ ```
16
+ <head>
17
+ <base href="/">
18
+ ...
19
+ </head>
20
+ ```
21
+
22
+ If you are deploying your app into a sub-context, set the base url to the url of the subcontext:
23
+
24
+ ```
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 (https://myapp.com/) but were broken when deployed to
33
+ a sub-context (e.g. https://myapp.com/subapp/), because in the sub-context all absolute urls would
34
+ resolve to the root context of the app. To prevent this, use relative urls throughout your app:
35
+
36
+ ```
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 your app is used by users with browsers that don't support `history.pushState` api,
47
+ the fallback mechanism provided by $location can get easily broken when we can't properly determine
48
+ the base url of the application.
49
+
50
+ In order to reduce the migration pain, we require that the base url is always specified when
51
+ `$location`'s `html5mode` is enabled.
You can’t perform that action at this time.
0 commit comments