Reputation: 71
I am going to make a project in angular but i have problem with ui-router. If i will go to the other state i have error: Cannot GET /404
There are my codes
routes.coffee
angular.module('havanaApp')
.config ($stateProvider, $urlRouterProvider, $locationProvider) ->
$locationProvider.html5Mode
enabled: true
requireBase: false
$urlRouterProvider.otherwise '/404'
$stateProvider
.state 'home',
url: '/'
views:
main:
templateUrl: 'views/main.html'
controller: 'HomeCtrl'
.state '404',
url: '/404'
views:
main:
templateUrl: 'views/pages/404.html'
controller: '404Ctrl'
gulpfile.js
gulp.task('connect', function() {
return $.connect.server({
root: '.tmp',
port: 8080,
livereload: true
})
});
What I'm doing wrong?
Upvotes: 1
Views: 346
Reputation: 71
Okay I fixed my problem.
Problem was in bad configuration my gulpfile.js. This code solved my issue
var ModRewrite = require('connect-modrewrite'),
...
gulp.task('connect', function() {
return $.connect.server({
root: '.tmp',
port: 8080,
livereload: true,
middleware: function(connect) {
return [
ModRewrite([
'!\\.html|\\.js|\\.css|\\.ico|\\.png|\\.gif|\\.jpg|\\.jpeg|\\.swf.*$ /index.html [NC,L]'
]),
connect.static('./app')
];
}
})
});
Upvotes: 2