Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell gulp-connect to open index.html regardless of the URL?

Tags:

I have the following gulp task:

gulp.task('connect', function() {   connect.server({     root: __dirname,     livereload: true   }); }); 

and the following Angular routes:

angular.module("MyApp", ["ngRoute"]).config(function($routeProvider, $locationProvider) {   $locationProvider.html5Mode(true);    $routeProvider     .when("/", {       controller: "DashboardCtrl",       templateUrl: "templates/dashboard.html"     })     .when("/advertiser", {       controller: "AdvertiserCtrl",       templateUrl: "templates/advertiser.html"     })     .otherwise({       redirectTo: "/"     }); }); 

When I visit / all works fine (the Dashboard appears).

But, visiting /advertiser results in "404 - Cannot GET /advertiser".

My main Angular file is index.html, which is opened properly for /, but not for /advertiser.

How could I tell Gulp to open index.html regardless of the URL?

like image 707
Misha Moroshko Avatar asked Apr 11 '14 13:04

Misha Moroshko


1 Answers

Alternatively you can use gulp-connect own option called fallback for that:

gulp.task('connect', function() {   connect.server({     root: 'path/',     livereload: true,     fallback: 'path/index.html'   }); }); 

No need for another package.

like image 79
Danilo Avatar answered Oct 06 '22 08:10

Danilo