I am using ui-router
, and have a profile
state that looks as follows:
.state('profile', {
url: "/profile",
templateUrl: "views/profile.html",
controller: 'ProfileCtrl',
resolve: {
currentUser: function(gamAuth){
return gamAuth.checkCurrentUser(config.userRol.user)
}
}
When I try to reload/refresh the page I get the following message:
Cannot GET /profile
The problem does not occur when I reload my 'landing page' at: http://localhost:9000/
, which has the following state in $stateProvider
:
.state('home', {
url: "/",
[...]
})
I am using: $locationProvider.html5Mode(true);
I tried providing absolute URL as suggested in the Decision Tree here
I also tried a number of suggestions found online, the most popular being something along these lines (placing it in the app.run()
section):
$state.transitionTo($state.current, $stateParams, {
reload: true,
inherit: false,
notify: true
});
All approaches were tested with and without the <base href="/">
tag being present in the <head>
of my index.html
.
Thank you for your time.
you need to enable html5mode to true if you want to use your url without '#' prefix.
Also you need to add your modRewrtie in as mentioned here
Prerequisite:
npm install --save-dev connect-modrewrite
When you have html5Mode enabled, the # character will no longer be used in your urls. The # symbol is useful because it requires no server side configuration. Without #, the url looks much nicer, but it also requires server side rewrites.
for more details about Rewrites to be setup:
https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With