2

In my application, when auth success, I am redirecting to /users. It works fine, and I am in users page too. But when I refresh the page, I am getting an error as:

Cannot GET /users

What does this mean?

As well my base location is / which is for login page, as well when user enter the path as /login - I am not redirecting to /. What is the issue?

Here is my router config :

(function(){    
    "use strict";    
    angular.module('meanOffice')
        .config(routeConfig);


    function routeConfig( $locationProvider, $stateProvider, $urlRouterProvider ){

        $stateProvider
            .state('login', {
                url:'/',
                templateUrl : 'app/views/pages/login/login.html',
                controller  : 'mainController as main'
            })
            .state('users', {
                url:'/users', //refresh getting error
                templateUrl : 'app/views/pages/users/users.html',
                controller  : 'usersController as users'
            })


        $locationProvider.html5Mode({
            enabled: true,
            requireBase: false
        });


        $urlRouterProvider.otherwise('/');//when type '/login' throw error

    }

})();
1
  • Could you show what Console of browser writes to you? and write, please, about the full content of error. Commented Nov 16, 2016 at 14:32

2 Answers 2

1

This means your server is not set up correctly.

In order to use HTML5 mode, all requests need to direct to your entrypoint. For more information on how to set up your server, please read: https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode

Sign up to request clarification or add additional context in comments.

2 Comments

I am using node as my server. if you have any specific approach please let me know
node on itself cannot be used as a server. I'm guessing you're using express as it is the most common server. You can check "Express Rewrites" on the linked page to see if your setup is correct.
0

Setup your express app:

app.route('/*').get(function(req, res) { 
    return res.sendFile(path.join(config.root, 'index.html')); 
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.