UI router + node/express JS page reloading unwantedly
<p>I have a strange issue with UI router and Express interacting together.
I've looked for solutions everywhere but nothing seems to be completely fixing the issue working.</p>

<p>When my app is in my /public folder and when i navigate to / it works fine and the url is getting changed as i click links.But whenever i go directly to /random/path ( <code>ui-sref="post/new"&gt;</code> ), it get intercepted by nodejs and say that this route doesn't exist.</p>

<p>I've fixed that issue using from a topic on that issue :</p>

<pre><code>    app.use('/', express.static(__dirname + '/public'));


    app.use(function (req, res) {
        res.sendFile(__dirname + '/public/');
    });
</code></pre>

<p>And now everything is working fine whenever i navigate directly to the path i want.</p>

<p>Now there is a new issue where the whole page will reload on every path change instead of just behaving like a client side app should and just load the view + controller.</p>

<p>The strange thing is that it's working as expected for 2 or 3 path.</p>

<p>Can anyone help ? </p>

<p>edit :</p>

<pre><code>    angular.module('App').config(function($stateProvider, $locationProvider,$urlRouterProvider) {
    $locationProvider.html5Mode(true);

    $urlRouterProvider.otherwise('/');
        $stateProvider
            .state('posts-new', {
                url:'/post/new',
                templateUrl: 'tmpl1.html'
            })
            .state('posts', {
                url:'/posts',
                templateUrl: 'tmpl2.html'
            });
    });
</code></pre>

<p>I've also tried with both base url /  and   <code>&lt;base href="/index.html"&gt;</code></p>